summaryrefslogtreecommitdiff
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorTobias Rapp <t.rapp@noa-archive.com>2017-01-18 10:27:01 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2017-01-19 01:54:49 +0100
commitc324e2c5db26cb1ac936b192dc1ac86f7b6db45c (patch)
tree59067454a764f762c04a078f9f78cfa1d46b73e4 /ffmpeg.c
parent6c43f33ac2e7606b2013f6261144389589394196 (diff)
ffmpeg: pass output stream duration as a hint to the muxer
Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 6d1e358a85..977708c069 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2908,6 +2908,10 @@ static int init_output_stream_streamcopy(OutputStream *ost)
if (ost->st->time_base.num <= 0 || ost->st->time_base.den <= 0)
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);
+
// copy disposition
ost->st->disposition = ist->st->disposition;
@@ -3333,6 +3337,11 @@ static int init_output_stream(OutputStream *ost, char *error, int error_len)
// copy timebase while removing common factors
if (ost->st->time_base.num <= 0 || ost->st->time_base.den <= 0)
ost->st->time_base = av_add_q(ost->enc_ctx->time_base, (AVRational){0, 1});
+
+ // copy estimated duration as a hint to the muxer
+ if (ost->st->duration <= 0 && ist && ist->st->duration > 0)
+ ost->st->duration = av_rescale_q(ist->st->duration, ist->st->time_base, ost->st->time_base);
+
ost->st->codec->codec= ost->enc_ctx->codec;
} else if (ost->stream_copy) {
ret = init_output_stream_streamcopy(ost);