mirror of
https://github.com/nyanmisaka/ffmpeg-rockchip.git
synced 2025-10-16 13:51:37 +08:00
fftools/ffmpeg_mux: set stream duration after the timebase is certainly known
Stop assuming the encoder knows the muxing timebase, which does not always have to hold (e.g. due to bitstream filters).
This commit is contained in:
@@ -914,10 +914,6 @@ static int streamcopy_init(const Muxer *mux, OutputStream *ost)
|
||||
ost->st->time_base = av_add_q(av_stream_get_codec_timebase(ost->st), (AVRational){0, 1});
|
||||
}
|
||||
|
||||
// copy estimated duration as a hint to the muxer
|
||||
if (ost->st->duration <= 0 && ist->st->duration > 0)
|
||||
ost->st->duration = av_rescale_q(ist->st->duration, ist->st->time_base, ost->st->time_base);
|
||||
|
||||
if (!ms->copy_prior_start) {
|
||||
ms->ts_copy_start = (mux->of.start_time == AV_NOPTS_VALUE) ?
|
||||
0 : mux->of.start_time;
|
||||
@@ -1283,6 +1279,12 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o,
|
||||
exit_program(1);
|
||||
}
|
||||
|
||||
// copy estimated duration as a hint to the muxer
|
||||
if (ost->ist && ost->ist->st->duration > 0) {
|
||||
ms->stream_duration = ist->st->duration;
|
||||
ms->stream_duration_tb = ist->st->time_base;
|
||||
}
|
||||
|
||||
return ost;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user