<div dir="ltr"><font face="monospace, monospace">Hi</font><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">I am trying to implement my first video filter. Now I am looking at the following example:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><a href="https://www.ffmpeg.org/doxygen/trunk/filtering_video_8c-example.html">https://www.ffmpeg.org/doxygen/trunk/filtering_video_8c-example.html</a><br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">In the function:</font></div><div><font face="monospace, monospace">  79    static int init_filters(const char *filters_descr)</font></div><div><font face="monospace, monospace">we have this:</font></div><div><font face="monospace, monospace">  87    AVRational time_base = fmt_ctx->streams[video_stream_index]->time_base;</font></div><div><font face="monospace, monospace">later this time_base is used as argument for the 'in' buffer.</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">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.</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">My questions:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">1. Is it always a better idea to use the demuxers time_base (<span style="color:rgb(34,34,34);font-family:monospace,monospace;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">AVRational time_base = fmt_ctx->streams[video_stream_index]->time_base;</span>) 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.</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">2. Isn't a rescale of the frame pts needed? Something like this:</font></div><div><br></div><div><font face="monospace, monospace"><div>  1    ret = avcodec_receive_frame(<span style="color:rgb(0,0,0);font-family:monospace,fixed;font-size:13px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-transform:none;white-space:pre-wrap;word-spacing:0px;background-color:rgb(251,252,253);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">dec_ctx</span>, frame);</div><div>  2    frame->pts = frame->best_effort_timestamp;</div><div>  3</div><div>  4    // Rescale the frame pts from decoder time_base back to stream time_base.</div><div>  5    frame->pts = av_rescale_q(frame->pts, dec_ctx->time_base, <span style="color:rgb(34,34,34);font-family:monospace,monospace;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">fmt_ctx->streams[video_stream_index]->time_base;</span>);<br></div><div>  6</div><div>  7    av_buffersrc_add_frame_flags(buffersrc_ctx, frame, AV_BUFFERSRC_FLAG_KEEP_REF);</div><div><br></div><div>Thanks.</div></font></div></div>