[Matroska-devel] question about not linear track timeline

Moritz Bunkus moritz at bunkus.org
Fri Mar 30 07:40:12 CEST 2012


Hey,

this is perfectly normal for video tracks which use B frames. Their
timecodes are in "presentation order" while they're stored in the file
in "decoding order": the decoder decodes them in the same order
they're located in the file, but the decoder will then re-order them
according to certain criteria that are unique to each codec type
before actually displaying the decoded picture.

For h.264 the rules how to order the timecodes for output into a
Matroska file (or MP4 file for that matter -- they do the same thing
we do) are pretty complex. If you want to get an idea how mkvmerge
does it here's the code:
https://github.com/mbunkus/mkvtoolnix/blob/master/src/common/mpeg4_p10.cpp
function "cleanup". It buffers all frames between two key
frames/recovery points, sorts them by their criteria (see the h.264
standard documents as well), assigns timecodes (either retrieved from
a source container or calculated from the timing information if the
source doesn't provide enough timecodes), and sorts them back in
decoding order.

This is not a bug. This is how video with B frames works.

Kind regards,
mo


More information about the Matroska-devel mailing list