Page 1 of 1

MKV file has incorrect length (Blu-ray, Twin Peaks example)

Posted: Tue Feb 21, 2017 3:38 am
by preserve
For an example of this issue, I'm using "Episode 6" from Disc 2 of the Twin Peaks "Entire Mystery" Blu-ray set.

Playing this MKV file created by MakeMKV, VLC reports the length as 47:24.

When VLC playback reaches 46:46 - which is the end of the actual content - it stops playback.

Bitrate Viewer reports the length correctly as 00:46:56:397 and 67526 frames.

MediaInfo reports the MKV length as 47:24 but correctly reports the video track length as 46:56:

Code: Select all

General
Unique ID                                : 228553115743896682116360536925934949938 (0xABF1BA9C6DD37DAFB39C40850E539632)
Complete name                            : T:\TV Blu-ray\Twin Peaks\twin.peaks.106.d2.t04.mkv
Format                                   : Matroska
Format version                           : Version 2
File size                                : 7.31 GiB
Duration                                 : 47mn 24s
Overall bit rate mode                    : Variable
Overall bit rate                         : 22.1 Mbps
Movie name                               : Twin Peaks: The Entire Mystery - Disc 2
Encoded date                             : UTC 2017-02-15 07:17:18
Writing application                      : MakeMKV v1.10.2 win(x86-release)
Writing library                          : libmakemkv v1.10.2 (1.3.3/1.4.4) win(x86-release)
Original source medium                   : Blu-ray

Video
ID                                       : 1
ID in the original source medium         : 4113 (0x1011)
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4.1
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 4 frames
Codec ID                                 : V_MPEG4/ISO/AVC
Duration                                 : 46mn 56s
Bit rate mode                            : Variable
Bit rate                                 : 17.4 Mbps
Maximum bit rate                         : 38.0 Mbps
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 23.976 (24000/1001) fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.350
Stream size                              : 5.70 GiB (78%)
Language                                 : English
Default                                  : No
Forced                                   : No

Audio #1
ID                                       : 2
ID in the original source medium         : 4352 (0x1100)
Format                                   : DTS
Format/Info                              : Digital Theater Systems
Format profile                           : MA / Core
Mode                                     : 16
Format settings, Endianness              : Big
Codec ID                                 : A_DTS
Duration                                 : 46mn 56s
Bit rate mode                            : Variable / Constant
Bit rate                                 : 4 686 Kbps / 1 509 Kbps
Channel(s)                               : 8 channels / 6 channels
Channel positions                        : Front: L C R, Side: L R, Back: L R, LFE / Front: L C R, Side: L R, LFE
Sampling rate                            : 48.0 KHz
Frame rate                               : 93.750 fps (512 spf)
Bit depth                                : 24 bits
Compression mode                         : Lossless / Lossy
Stream size                              : 1.54 GiB (21%)
Title                                    : Surround 7.1
Language                                 : English
Default                                  : Yes
Forced                                   : No

Audio #2
ID                                       : 3
ID in the original source medium         : 4353 (0x1101)
Format                                   : AC-3
Format/Info                              : Audio Coding 3
Mode extension                           : CM (complete main)
Format settings, Endianness              : Big
Codec ID                                 : A_AC3
Duration                                 : 47mn 24s
Bit rate mode                            : Constant
Bit rate                                 : 192 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 48.0 KHz
Frame rate                               : 31.250 fps (1536 spf)
Compression mode                         : Lossy
Stream size                              : 65.1 MiB (1%)
Title                                    : Stereo
Language                                 : English
Default                                  : No
Forced                                   : No

Text
ID                                       : 4
ID in the original source medium         : 4608 (0x1200)
Format                                   : PGS
Codec ID                                 : S_HDMV/PGS
Codec ID/Info                            : Picture based subtitle format used on BDs/HD-DVDs
Duration                                 : 44mn 0s
Bit rate                                 : 32.4 Kbps
Count of elements                        : 1182
Stream size                              : 10.2 MiB (0%)
Language                                 : English
Default                                  : No
Forced                                   : No

Menu
00:00:00.000                             : en:Chapter 01
00:12:37.506                             : en:Chapter 02
00:24:06.736                             : en:Chapter 03
00:32:39.457                             : en:Chapter 04
00:46:07.931                             : en:Chapter 05
mkvinfo.exe reports the length as 00:47:24.896 and also has a "ChapterTimeEnd" at the same point:

Code: Select all

+ EBML head
|+ EBML version: 1
|+ EBML read version: 1
|+ EBML maximum ID length: 4
|+ EBML maximum size length: 8
|+ Doc type: matroska
|+ Doc type version: 2
|+ Doc type read version: 2
+ Segment, size 7853855177
|+ Seek head (subentries will be skipped)
|+ EbmlVoid (size: 1021)
|+ Segment information
| + Timecode scale: 1000000
| + Muxing application: libmakemkv v1.10.2 (1.3.3/1.4.4) win(x86-release)
| + Writing application: MakeMKV v1.10.2 win(x86-release)
| + Duration: 2844.896s (00:47:24.896)
| + Title: Twin Peaks: The Entire Mystery - Disc 2
| + Date: Wed Feb 15 07:17:18 2017 UTC
| + Segment UID: 0xab 0xf1 0xba 0x9c 0x6d 0xd3 0x7d 0xaf 0xb3 0x9c 0x40 0x85 0x0e 0x53 0x96 0x32
|+ Segment tracks
| + A track
|  + Track number: 1 (track ID for mkvmerge & mkvextract: 0)
|  + Track UID: 1
|  + Track type: video
|  + Default flag: 0
|  + Lacing flag: 0
|  + MinCache: 1
|  + Codec ID: V_MPEG4/ISO/AVC
|  + CodecPrivate, length 133 (h.264 profile: High @L4.1)
|  + Default duration: 41.708ms (23.976 frames/fields per second for a video track)
|  + Video track
|   + Pixel width: 1920
|   + Pixel height: 1080
|   + Display width: 1920
|   + Display height: 1080
| + A track
|  + Track number: 2 (track ID for mkvmerge & mkvextract: 1)
|  + Track UID: 2
|  + Track type: audio
|  + Default flag: 1
|  + Lacing flag: 1
|  + Codec ID: A_DTS
|  + Language: eng
|  + Default duration: 10.667ms (93.750 frames/fields per second for a video track)
|  + Name: Surround 7.1
|  + Audio track
|   + Sampling frequency: 48000
|   + Channels: 8
|   + Bit depth: 24
| + A track
|  + Track number: 3 (track ID for mkvmerge & mkvextract: 2)
|  + Track UID: 3
|  + Track type: audio
|  + Default flag: 0
|  + Lacing flag: 1
|  + Codec ID: A_AC3
|  + Language: eng
|  + Default duration: 32.000ms (31.250 frames/fields per second for a video track)
|  + Name: Stereo
|  + Audio track
|   + Sampling frequency: 48000
|   + Channels: 2
| + A track
|  + Track number: 4 (track ID for mkvmerge & mkvextract: 3)
|  + Track UID: 4
|  + Track type: subtitles
|  + Default flag: 0
|  + Lacing flag: 0
|  + Codec ID: S_HDMV/PGS
|  + Language: eng
| + EbmlVoid (size: 35)
|+ Chapters
| + EditionEntry
|  + EditionFlagHidden: 0
|  + EditionFlagDefault: 1
|  + EditionUID: 8489422256576934061
|  + ChapterAtom
|   + ChapterUID: 13516520389186663928
|   + ChapterTimeStart: 00:00:00.000000000
|   + ChapterFlagHidden: 0
|   + ChapterFlagEnabled: 1
|   + ChapterTimeEnd: 00:12:37.506750000
|   + ChapterDisplay
|    + ChapterString: Chapter 01
|    + ChapterLanguage: eng
|  + ChapterAtom
|   + ChapterUID: 16850864592543412137
|   + ChapterTimeStart: 00:12:37.506750000
|   + ChapterFlagHidden: 0
|   + ChapterFlagEnabled: 1
|   + ChapterTimeEnd: 00:24:06.736958333
|   + ChapterDisplay
|    + ChapterString: Chapter 02
|    + ChapterLanguage: eng
|  + ChapterAtom
|   + ChapterUID: 10780130994244117348
|   + ChapterTimeStart: 00:24:06.736958333
|   + ChapterFlagHidden: 0
|   + ChapterFlagEnabled: 1
|   + ChapterTimeEnd: 00:32:39.457500000
|   + ChapterDisplay
|    + ChapterString: Chapter 03
|    + ChapterLanguage: eng
|  + ChapterAtom
|   + ChapterUID: 4106946188292836056
|   + ChapterTimeStart: 00:32:39.457500000
|   + ChapterFlagHidden: 0
|   + ChapterFlagEnabled: 1
|   + ChapterTimeEnd: 00:46:07.931833333
|   + ChapterDisplay
|    + ChapterString: Chapter 04
|    + ChapterLanguage: eng
|  + ChapterAtom
|   + ChapterUID: 9511611825237125789
|   + ChapterTimeStart: 00:46:07.931833333
|   + ChapterFlagHidden: 0
|   + ChapterFlagEnabled: 1
|   + ChapterTimeEnd: 00:47:24.896000000
|   + ChapterDisplay
|    + ChapterString: Chapter 05
|    + ChapterLanguage: eng
|+ EbmlVoid (size: 1021)
|+ Cluster
It's a minor issue because the resulting MKVs that have this issue seem to playback okay, but it is kind of annoying because I do like to use VLC to quickly grab the file's runtime, and that's not possible with this problem. It would be great to know the cause of this problem, and if it can be fixed for a future release of MakeMKV.

Re: MKV file has incorrect length (Blu-ray, Twin Peaks examp

Posted: Tue Feb 21, 2017 5:55 am
by ndjamena
You cut off the rest of the track info.

How long does it say the audio and subtitle tracks are?

Re: MKV file has incorrect length (Blu-ray, Twin Peaks examp

Posted: Tue Feb 21, 2017 10:50 am
by preserve
Thanks for taking the time to look at it, I have updated the first post with the full information.

Now that you draw my attention to it, it looks like the issue might be a secondary audio track that is for some reason longer than the video track, which seems pretty strange and is something I never would have imagined.

Have I assessed it correctly?

Re: MKV file has incorrect length (Blu-ray, Twin Peaks examp

Posted: Tue Feb 21, 2017 11:02 am
by ndjamena
Yes, an MKV's duration is the difference between the lowest timecode and the highest, not the length of the most convenient track.

If an audio track extends beyond the bounds of a video track its bounds must be including the mkv duration as well.

Congratulations, you've discovered one of the reasons Track Statistics Tags were added to MKVs, although it was the Star Trek: The Next Generation that was causing the problem that time.

I had to figure out what the hell was going on WITHOUT MediaInfo being able to give me any useful information.

I did have a Powershell script written to fix the problem using MKVMerge at one point... I think FFMPEG has a command to make all tracks the same length...

If you really need it fixed.

Re: MKV file has incorrect length (Blu-ray, Twin Peaks examp

Posted: Wed Feb 22, 2017 2:33 am
by preserve
ndjamena wrote:If you really need it fixed.
Nope, I am satisfied knowing how and why it happens, most helpful - thanks!

Re: MKV file has incorrect length (Blu-ray, Twin Peaks example)

Posted: Sun Jan 03, 2021 10:58 am
by LimaAlphaHotel
I realise this is a 3 year old thread but I have just started on my Star Trek: TNG BluRays and encountered this problem that ndjamena has already fixed:
Congratulations, you've discovered one of the reasons Track Statistics Tags were added to MKVs, although it was the Star Trek: The Next Generation that was causing the problem that time.
I did have a Powershell script written to fix the problem using MKVMerge at one point... I think FFMPEG has a command to make all tracks the same length...
How did you fix it - use MKVMerge to truncate it to the video track length or somehow extend the other tracks to the length of the longest audio track? Can you share the script, or is it lost to time?

Thanks in anticipation.