Log in

View Full Version : mkv - real duration of incomplete file


zn
13th August 2018, 10:06
I want to be able to find duration of unfinished/incomplete mkv file. this shows wrong time:
ffmpeg -i incomplete.mkv
mkvinfo incomplete.mkv
mediainfo --Full --Language=raw incomplete.mkv

I found slow solution to find real duration (takes 3 minutes on 20 GB mkv on SSD):
mkvinfo -v incomplete.mkv (long output, long runtime)
mkvinfo -v incomplete.mkv | tail (short output, 3 minutes runtime)

| + Simple block: track number 1, 1 frame(s), timestamp 01:12:44.526000000
| + Frame with size 104544
| + Simple block: key, track number 2, 1 frame(s), timestamp 01:12:44.457000000
| + Frame with size 366
| + Simple block: track number 1, 1 frame(s), timestamp 01:12:44.485000000
| + Frame with size 97446
| + Simple block: key, track number 2, 1 frame(s), timestamp 01:12:44.478000000
| + Frame with size 350
| + Simple block: track number 1, 1 frame(s), timestamp 01:12:44.505000000
| + Frame with size 79780

May be there is a faster way to find timestamps of last frames in mkv?

I have tried to join first and last 1mb of mkv file, but mkvinfo cannot recognize timestamps after split:
head -c 1000000 incomplete.mkv > 1.mkv
tail -c 1000000 incomplete.mkv > 2.mkv
cat 1.mkv 2.mkv>3.mkv
mkvinfo -v 2.mkv
mkvinfo -v 3.mkv

| + Simple block: track number 1, 1 frame(s), timestamp 00:00:00.188000000
| + Frame with size 39003
| + Simple block: key, track number 2, 1 frame(s), timestamp 00:00:00.205000000
| + Frame with size 320
| + Simple block: track number 1, 1 frame(s), timestamp 00:00:00.229000000
| + Frame with size 40589
| + (Unknown element: DummyElement; ID: 0x1d21c1e6 size: 103)
| + (Unknown element: DummyElement; ID: 0x1f577efb size: 117)
| + (Unknown element: DummyElement; ID: 0x7a32 size: 19)
| + (Known element, but invalid at this position: Frame number; ID: 0xcd size: 18)
| + (Known element, but invalid at this position: Time slice; ID: 0xe8 size: 28)
| + (Known element, but invalid at this position: Block additional ID; ID: 0xcb size: 34)
| + (Unknown element: DummyElement; ID: 0x1d826e67 size: 10912)
| + (Unknown element: DummyElement; ID: 0x59f4 size: 1252875)

hubblec4
16th August 2018, 17:43
Often is the duration of an mkv not proper, for example an audio track is larger then a video track.
My chapterEdtior scans the Clusters to find the last video time stamp. This takes for the first time ever 2-3 min.

MKVToolNix Statistics Tags are the base for MediaInfo's output (duration).
You could try to insert these Stats-Tags, but this will also take 2-3min.

There is no other way possible (atm).