[FFmpeg-devel] Is AV_TIME_BASE required to be a full millisecond?

Michael Fabian 'Xaymar' Dirks michael.dirks at xaymar.com
Wed May 19 00:28:01 EEST 2021


On 2021-05-18 22:09, Nicolas George wrote:
> Michael Fabian 'Xaymar' Dirks (12021-05-18):
>> while tracking some time stamp issues unique to FFmpeg I noticed
>> AV_Time_BASE(_Q) being present quite often, which appears to be a
>> value to define time stamps in milliseconds. Tracking it back to its
>> origin I could find very little to no information about why this value
>> was chosen. All I know so far is that it was chosen for compatibility
>> with very early versions of FFmpeg.
> Microsecond timestamps are a good compromise that allows enough
> precision for almost everything while having a wide enough range on
> normal 64 bits arithmetic. Using nanosecond, for example, would let
> timestamps overflow after six centuries, which is too close for comfort.

I'm unsure if the latter statement is a joke or not.

>> Does FFmpeg require this value to be a full millisecond? Or is it
>> possible to adjust this to microseconds and "fix" many of the time
>> stamp issues that occur? While it seems to be possible to work-around
>> this issue on a muxer/demuxer level, the underlying issue in FFmpeg
>> would still be present. At the moment, most non-integer ms framerates
>> and sample rates end up performing weird without post-processing.
> Please tell what value you would recommend instead of a microsecond, and
> explain precisely which weirdness it would allow to fix and how.
>
> Regards,

I'm not entirely sure what significance AV_TIME_BASE has so far, as it seems to define the global time base to be 1µs - yet files are created with 1ms precision instead. My suggestion would be to move to 100µs which gives the necessary precision to be less confusing for most demuxers that aren't FFmpeg. This cuts the available time by 10 for formats that move to it, while formats which support per-track unique time bases would be unaffected.

At least to my understanding so far, both ISO BMF and Matroska/WebM have support for 64-bit time stamps. I have not yet looked into other formats.

-- 
Sincerely | Mit freundlichen Grüßen

Michael Fabian 'Xaymar' Dirks
Software Designer & Engineer




More information about the ffmpeg-devel mailing list