[FFmpeg-devel] [PATCH] avformat/matroskaenc: Allow changing the time stamp precision via option

Michael Fabian 'Xaymar' Dirks michael.dirks at xaymar.com
Thu May 20 22:12:29 EEST 2021


On 2021-05-20 20:54, Nicolas George wrote:
> Michael Fabian 'Xaymar' Dirks (12021-05-20):
>> Well, it's a combination of many things really, not bad math itself.
>> 1ms works perfectly for the frame rates of 1, 2, 4, 5, 8, 10, 20, 25,
>> 40, 50, 100, 125, 200, 250, 500, and 1000. For any other rate, you
>> will have to look at the actual timestamp of N clusters and M blocks,
>> where N and M are undefined. N and M are undefined because there is no
>> solution that works for every rate, other than having a per-track
>> rational time base
>> (https://github.com/ietf-wg-cellar/matroska-specification/pull/425).
>>
>> If there were zero dropped/skipped frames in the encoding process (we
>> have a packet for every frame), then it can be worked around by
>> looking ahead for 1 second, but that is a lot to ask from an
>> application just to know the actual rate.
> Why would an application need to know the actual frame rate with so much
> precision?

There are plenty of reasons to know the actual frame rate with high precision. Editing software needs to know this to initialize effects, timelines and projects. Players need it to queue the right amount of frames at the right time. Transcoding requires it to encode at the right rate. Remuxing requires it so that it doesn't end up as "variable" without requiring extensive extra parameters and scripting to get FFmpeg to like the MKV file. I don't see a single reason to not offer users the choice to increase the precision to their liking.

Hopefully in the future Matroska adopts rational time stamps for the tracks, in order to permanently fix the issue.

>> Matroska is far from perfect as it is right now, so more vocal input
>> on the IETF standardization process for Matroska/WebM might be
>> helpful.
> To be really helpful, it is necessary to understand the issue properly.
> In my experience, most people who complain about the precision of
> timestamps are using them wrong.

I have yet to see anyone use timestamps wrong. Timestamps should be as accurate as possible, especially when you consider that even with 1µs of precision in a 64-bit timestamp, you can still mux for at least 584000 years before you have to wrap around to zero again.

-- 
Sincerely | Mit freundlichen Grüßen

Michael Fabian 'Xaymar' Dirks
Software Designer & Engineer




More information about the ffmpeg-devel mailing list