[Libav-user] Erratic encoding issue: Crazy framerates.

Robert Krüger krueger at lesspain.de
Thu Sep 3 18:23:18 CEST 2015

On Thu, Sep 3, 2015 at 5:41 PM, Talgorn François-Xavier <
fxtalgorn-at-yahoo.fr at ffmpeg.org> wrote:

> Hi Krueger,
> Thanks for your reply.
> I did check the timestamps and durations of packets.
> It appears that respectives timestamps (original/encoded) are in different
> formats but consistent (incremental).
> I set the timebase for encoded file to the same as the original
> (in_ctx->format_ctx is the original context).
>     o_codec_ctx->time_base.num =
> in_ctx->format_ctx->streams[in_ctx->video_stream_idx]->codec->time_base;
>     o_codec_ctx->time_base.den =
> in_ctx->format_ctx->streams[in_ctx->video_stream_idx]->codec->time_base;
> I don't know if this is OK to duplicate a timebase from H264 to be used in
> a MP4 context.
> Since it defines the frame rate only (not the ticks/frame) it should OK I
> guess.
> no, it does not. mov/mp4 don't have a concept like frame rate.

The encoder gives you packets that have timestamps that are based on what
you gave the encoder as timebase. The muxer has the freedom to change that
timebase in avformat_write_header and if it does, the packets you get from
the encoder have incorrect timestamps, if you don't rescale them to the
timebase of the AVStream modified by the muxer. Check the example muxing.c
in the docs. You have to do what's done there (see line 83). If you don't,
what you describe (incorrect frame rate) may very well be the result.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20150903/dff0bbf4/attachment.html>

More information about the Libav-user mailing list