aboutsummaryrefslogtreecommitdiffstats
path: root/fftools/ffmpeg_mux.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2024-09-10 10:55:28 +0200
committerAnton Khirnov <anton@khirnov.net>2024-09-26 18:25:21 +0200
commit238f439992f7e77609c2dc7ab6230da756c460b8 (patch)
tree4ff7b811fd563bca9f039ff13ab212bccca567f4 /fftools/ffmpeg_mux.c
parent1ebd521a4e503c1e4697273a984e6de2c5f8886d (diff)
downloadffmpeg-238f439992f7e77609c2dc7ab6230da756c460b8.tar.gz
fftools/ffmpeg_enc: do not set AVStream timebase directly
Instead, pass the encoder context to of_stream_init() and have the muxer take the timebase from there. Note that the muxer can currently access the codec context directly, but that will change in future commits. This is a step towards decoupling encoders from muxers.
Diffstat (limited to 'fftools/ffmpeg_mux.c')
-rw-r--r--fftools/ffmpeg_mux.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 71ff9b45ab..71a771052f 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -608,12 +608,19 @@ static int bsf_init(MuxStream *ms)
return 0;
}
-int of_stream_init(OutputFile *of, OutputStream *ost)
+int of_stream_init(OutputFile *of, OutputStream *ost,
+ const AVCodecContext *enc_ctx)
{
Muxer *mux = mux_from_of(of);
MuxStream *ms = ms_from_ost(ost);
int ret;
+ if (enc_ctx) {
+ // use upstream time base unless it has been overridden previously
+ if (ost->st->time_base.num <= 0 || ost->st->time_base.den <= 0)
+ ost->st->time_base = av_add_q(enc_ctx->time_base, (AVRational){0, 1});
+ }
+
/* initialize bitstream filters for the output stream
* needs to be done here, because the codec id for streamcopy is not
* known until now */