[FFmpeg-devel] [PATCH 04/25] fftools/ffmpeg_enc: always use video frame durations when available

Anton Khirnov anton at khirnov.net
Thu Apr 20 00:12:12 EEST 2023


Quoting James Almer (2023-04-19 22:42:24)
> On 4/19/2023 4:52 PM, Anton Khirnov wrote:
> > diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
> > index e3dc858bc3..9aaec277f1 100644
> > --- a/fftools/ffmpeg_enc.c
> > +++ b/fftools/ffmpeg_enc.c
> > @@ -1005,24 +1005,17 @@ static void do_video_out(OutputFile *of,
> >       AVRational frame_rate;
> >       int64_t nb_frames, nb_frames_prev, i;
> >       double duration = 0;
> > -    InputStream *ist = ost->ist;
> >       AVFilterContext *filter = ost->filter->filter;
> >   
> > -    frame_rate = av_buffersink_get_frame_rate(filter);
> > -    if (frame_rate.num > 0 && frame_rate.den > 0)
> > -        duration = 1/(av_q2d(frame_rate) * av_q2d(enc->time_base));
> > +    if (next_picture)
> > +        duration = lrintf(next_picture->duration * av_q2d(next_picture->time_base) / av_q2d(enc->time_base));
> 
> llrint(). You're passing it a double argument, and long int is 32 bits 
> on Windows.

I'm just reusing the code as it was before, except for reducing the
conditions and using the frame timebase instead of the stream one. Given
how fragile this all is, I'd rather not do too many changes at once.
The whole rounding step is rather questionable, since the integer result
is assigned to a double. But I'd say that belongs in a separate patch.

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list