[FFmpeg-devel] [PATCH 3/3] fftools/ffmpeg: get EOF timestamp from filter.
Nicolas George
george at nsup.org
Thu Jun 25 21:35:18 EEST 2020
Signed-off-by: Nicolas George <george at nsup.org>
---
fftools/ffmpeg.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
This breaks fate-lagarith-ticket4119-cfr. I have decided to leave it.
The new output is more correct. The input ends with:
pts_time=2.000000
duration_time=0.040000
It is right that the output file ends at 2.04, not at 3.00.
I did not change the ref file, because it was there for something: there
may be a bug to fix for ticket 4119, but the fix that was done was
wrong.
In fact, I suspect 9f6d48d696d679de77e8cb513d5f64cd708ed86f should be
reverted entirely.
Or we could just drop this chunk of code and insert the fps filter.
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 3919f2ab62..b1c7745d93 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1075,7 +1075,7 @@ static void do_video_out(OutputFile *of,
duration = lrintf(next_picture->pkt_duration * av_q2d(ist->st->time_base) / av_q2d(enc->time_base));
}
- if (!next_picture) {
+ if (!next_picture && sync_ipts == AV_NOPTS_VALUE) {
//end, flushing
nb0_frames = nb_frames = mid_pred(ost->last_nb0_frames[0],
ost->last_nb0_frames[1],
@@ -1152,6 +1152,8 @@ static void do_video_out(OutputFile *of,
default:
av_assert0(0);
}
+ if (!next_picture)
+ nb0_frames = FFMAX(nb_frames, 1) - 1;
}
nb_frames = FFMIN(nb_frames, ost->max_frames - ost->frame_number);
@@ -1477,8 +1479,11 @@ static int reap_filters(int flush)
av_log(NULL, AV_LOG_WARNING,
"Error in av_buffersink_get_frame_flags(): %s\n", av_err2str(ret));
} else if (flush && ret == AVERROR_EOF) {
- if (av_buffersink_get_type(filter) == AVMEDIA_TYPE_VIDEO)
- do_video_out(of, ost, NULL, AV_NOPTS_VALUE);
+ if (av_buffersink_get_type(filter) == AVMEDIA_TYPE_VIDEO) {
+ int64_t pts = av_buffersink_get_pts(filter);
+ float_pts = compute_encoder_pts_from_filter_pts(filter, of, enc, &pts);
+ do_video_out(of, ost, NULL, float_pts);
+ }
}
break;
}
--
2.27.0
More information about the ffmpeg-devel
mailing list