[FFmpeg-devel] [PATCH] Compute individual stream durations in matroska muxer. Write them as binary tags. Parse the binary tags in matroska demuxer, and write them to AVStream

Reimar Döffinger Reimar.Doeffinger at gmx.de
Wed Jul 29 05:12:05 CEST 2015

On 29.07.2015, at 05:00, Reimar Döffinger <Reimar.Doeffinger at gmx.de> wrote:
> On 29.07.2015, at 03:10, Sasi Inguva <isasi at google.com> wrote:
>> A little context on why I need this. I use individual stream durations to
>> validate , if the outputs after transcoding have the same stream durations.
>> For this we need to know the stream durations through a quick parse of the
>> header of the file, since demuxing the whole file is too slow. We can have
>> some video files, for example slide show videos etc. , where audio might be
>> of short duration and video very long, so it is not always the case that
>> video and audio of our input will be of the same duration.
> If validating a transcode is all it is used for, printing the information at the end of the transcode or even making the validation part of FFmpeg seems potentially easier/cleaner/more generic.
> Btw please change the commit message to standard format (one line very short description, starting with the affected module name followed by colon, then empty line, then long description).

And I forgot: reading the stream durations from a mkv file should not require demuxing the whole file at all.
Worst case it requires binary search through the seek entries for the last one still containing the stream and then linear demuxing from there to the end. If you know the expected durations the binary search path probably shouldn't even be necessary.
I am also unsure the duration values you calculate in the muxer are correct, it looks to me like you store the end timestamp. However that is not the duration if the stream does not start at timestamp 0...

More information about the ffmpeg-devel mailing list