[Libav-user] Updated libav/ffmpeg tutorial

wm4 nfxjfg at googlemail.com
Tue Mar 3 12:47:54 CET 2015


On Tue, 3 Mar 2015 12:27:51 +0300
Max Vlasov <max.vlasov at gmail.com> wrote:

> Hi again,
> 
> after reading more information about how currently ffmpeg/libav is
> interrelated (basically ffmpeg borrows from libav, but not vice versa), I
> decided to look into the sources to see how av_frame_get_best_effort_timestamp
> works.
> 
> It turns out that it is just a get accessor for best_effort_timestamp field
> and the corresponding set accessor (av_frame_set_best_effort_timestamp) is
> called twice (in avcodec_decode_video2 and in avcodec_decode_audio4) in the
> utils.c with a similar lines
> 
>   av_frame_set_best_effort_timestamp(..., guess_correct_pts(avctx, .... );
> 
> There's no any "best_effort" symbols in libav, but the function
> guess_correct_pts
> exists in libav, the code of both versions (ffmpeg vs libav) looks almost
> identical.
> 
> So, probably one who wants to keep compatibility with both libraries should
> conditionally use either the field accessor (ffmpeg) or function (libav),
> but the feature actually exists in both libraries. Probably looking at
> how guess_correct_pts
> is called in ffmpeg one might probably always use guess_correct_pts instead
> of av_frame_get_best_effort_timestamp, but this is just a hypothesis.

As I said, it's only a helper. What you really should do is always
using the PTS, and if the PTS is not available, use the DTS. The extra
heuristics are useful only for broken files and such; and they can be
better than what best_effort_timestamp does.

So if you're doing something simple that only needs to work with a
specific FFmpeg version, use best_effort_timestamp. If you're doing
something more advanced that should in general be more robust and
should also work on Libav, write your own code.


More information about the Libav-user mailing list