[Libav-user] Changing time_bases for decoder(mpeg2video) when sending packets with avcodec_send_packet().

Hristo Ivanov hivanov.ffmailing at gmail.com
Mon Jun 4 13:51:43 EEST 2018


I am trying to implement my first video filter. Now I am looking at the
following example:


In the function:
  79    static int init_filters(const char *filters_descr)
we have this:
  87    AVRational time_base =
later this time_base is used as argument for the 'in' buffer.

In the example there is no rescaling of the packets/frames, my guest is
that this is omitted in order to have a simpler example and the example
only works with decoders which do not change their timebase.

My questions:

1. Is it always a better idea to use the demuxers time_base (AVRational
time_base = fmt_ctx->streams[video_stream_index]->time_base;) as argument
to the input buffer? My guest is yes, as we have seen in the previous
messages the decoders time_base can change when packets are sent to be

2. Isn't a rescale of the frame pts needed? Something like this:

  1    ret = avcodec_receive_frame(dec_ctx, frame);
  2    frame->pts = frame->best_effort_timestamp;
  4    // Rescale the frame pts from decoder time_base back to stream
  5    frame->pts = av_rescale_q(frame->pts, dec_ctx->time_base,
  7    av_buffersrc_add_frame_flags(buffersrc_ctx, frame,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20180604/477b2a01/attachment.html>

More information about the Libav-user mailing list