diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-04-15 09:46:29 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-04-24 16:56:06 +0200 |
commit | c94e9d03b44d21282418dfb6c84f4f7942d4db03 (patch) | |
tree | c8be2932d838aec8d9917b72a833dd91f1c0b190 /fftools | |
parent | cd3049277343abd336f941e07549727d6e1b3ed8 (diff) | |
download | ffmpeg-c94e9d03b44d21282418dfb6c84f4f7942d4db03.tar.gz |
fftools/ffmpeg_enc: always use video frame durations when available
Previously they would only be used with trivial filtergraphs, because
filters did not handle frame durations. That is no longer true - most
filters process frame durations properly (there may still be some that
don't - this change will help finding and fixing them).
Improves output video frame durations in a number of FATE tests.
Diffstat (limited to 'fftools')
-rw-r--r-- | fftools/ffmpeg_enc.c | 19 |
1 files changed, 6 insertions, 13 deletions
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)); - if(ist && ist->st->start_time != AV_NOPTS_VALUE && ist->first_dts != AV_NOPTS_VALUE && ost->frame_rate.num) + if (duration <= 0 && ost->frame_rate.num) duration = FFMIN(duration, 1/(av_q2d(ost->frame_rate) * av_q2d(enc->time_base))); - if (!ost->filters_script && - !ost->filters && - (nb_filtergraphs == 0 || !filtergraphs[0]->graph_desc) && - next_picture && - ist && - lrintf(next_picture->duration * av_q2d(ist->st->time_base) / av_q2d(enc->time_base)) > 0) { - duration = lrintf(next_picture->duration * av_q2d(ist->st->time_base) / av_q2d(enc->time_base)); - } + frame_rate = av_buffersink_get_frame_rate(filter); + if (duration <= 0 && frame_rate.num > 0 && frame_rate.den > 0) + duration = 1/(av_q2d(frame_rate) * av_q2d(enc->time_base)); if (!next_picture) { //end, flushing |