Hi

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

https://www.ffmpeg.org/doxygen/trunk/filtering_video_8c-example.html

In the function:
  79    static int init_filters(const char *filters_descr)
we have this:
  87    AVRational time_base =
fmt_ctx->streams[video_stream_index]->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
decoded.

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;
  3
  4    // Rescale the frame pts from decoder time_base back to stream
time_base.
  5    frame->pts = av_rescale_q(frame->pts, dec_ctx->time_base,
fmt_ctx->streams[video_stream_index]->time_base;);
  6
  7    av_buffersrc_add_frame_flags(buffersrc_ctx, frame,
AV_BUFFERSRC_FLAG_KEEP_REF);

Thanks.
_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to