[Ffmpeg-devel] [PATCH] mov fix fps detection

Michael Niedermayer michaelni
Tue Aug 8 11:13:55 CEST 2006


On Tue, Aug 08, 2006 at 12:26:08AM +0200, Baptiste Coudurier wrote:
> Hi
> Here is an attempt to fix somewhat fps detection.
> Quoting from ISO 14496-12:
> "The time to sample boxes must give non-zero durations for all samples
> with the possible exception of the last
> one. Durations in the `stts' box are strictly positive (non-zero),
> except for the very last entry, which may be
> zero. This rule derives from the rule that no two time-stamps in a
> stream may be the same. Great care must
> be taken when adding samples to a stream, that the sample that was
> previously last may need to have a non-
> zero duration established, in order to observe this rule. If the
> duration of the last sample is indeterminate, use
> an arbitrary small value and a `dwell' edit."
> According to what I understand, It could be possible to safely ignore
> stts value of last packet, I chose to copy last duration, since it
> illustrates well 'an arbitrary small value' and fix fps detection
> problem. Duration will then be updated accordingly, other change is to
> avoid overwriting readjusted duration afterwards.
> Maybe I should ensure that entries == 2 ?
> Is that acceptable ?

actually i think that the timebase should be set to exactly what is in
the header even if all durations are constant and >1
and optionally a approximate framerate which ignores the last duration 
could be stored in AVStream.r_frame_rate by the demuxer, this would probably
need a small change to libavformat/utils.c so the generic framerate
guessing code doesnt override what the demuxer set

Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is

More information about the ffmpeg-devel mailing list