@@ -1486,13 +1486,12 @@ static void do_video_stats(OutputStream *ost, int frame_size)
static void finish_output_stream(OutputStream *ost)
{
OutputFile *of = output_files[ost->file_index];
- int i;
ost->finished = ENCODER_FINISHED | MUXER_FINISHED;
if (of->shortest) {
- for (i = 0; i < of->ctx->nb_streams; i++)
- output_streams[of->ost_index + i]->finished = ENCODER_FINISHED | MUXER_FINISHED;
+ int64_t end = av_rescale_q(ost->sync_opts - ost->first_pts, ost->mux_timebase, AV_TIME_BASE_Q);
+ of->recording_time = FFMIN(of->recording_time, end);
}
}
@@ -2089,10 +2088,6 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
}
}
- /* force the input stream PTS */
- if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO)
- ost->sync_opts++;
-
if (av_packet_ref(opkt, pkt) < 0)
exit_program(1);
@@ -2116,6 +2111,8 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
opkt->duration = av_rescale_q(pkt->duration, ist->st->time_base, ost->mux_timebase);
+ ost->sync_opts += opkt->duration;
+
output_packet(of, opkt, ost, 0);
}
Don't mark all streams as finished, instead make sync_opts keep track of the stream's duration, and set recording_time to it, same as in transcoding paths. Fixes tickets #9512 and #9513. Signed-off-by: James Almer <jamrial@gmail.com> --- fftools/ffmpeg.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)