summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2024-04-01 06:29:16 +0200
committerAnton Khirnov <anton@khirnov.net>2024-04-09 10:34:18 +0200
commit9d5bf2d69e6ad85adbf8a673929192e0b07bc080 (patch)
treeff1797ffa77726a9cc6089e114b9645815c4540a
parent606c71bb117ab32eb91cfa5b8e14594023fb1175 (diff)
fftools/ffmpeg_filter: pass enc_timebase through OutputFilterOptions
Reduces the need to access OutputStream, which will allow decoupling filtering from encoding in future commits.
-rw-r--r--fftools/ffmpeg.h7
-rw-r--r--fftools/ffmpeg_filter.c2
-rw-r--r--fftools/ffmpeg_mux_init.c4
3 files changed, 9 insertions, 4 deletions
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 300ad8a987..56c2fedcc4 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -273,6 +273,11 @@ typedef struct OutputFilterOptions {
int64_t ts_offset;
+ /* Desired output timebase.
+ * Numerator can be one of EncTimeBase values, or 0 when no preference.
+ */
+ AVRational output_tb;
+
// A combination of OFilterFlags.
unsigned flags;
} OutputFilterOptions;
@@ -529,8 +534,6 @@ typedef struct OutputStream {
AVStream *st; /* stream in the output file */
- AVRational enc_timebase;
-
Encoder *enc;
AVCodecContext *enc_ctx;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 5f2dbc387e..0b78898af0 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -780,7 +780,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost,
ofp->flags = opts->flags;
ofp->ts_offset = opts->ts_offset;
- ofp->enc_timebase = ost->enc_timebase;
+ ofp->enc_timebase = opts->output_tb;
switch (ost->enc_ctx->codec_type) {
case AVMEDIA_TYPE_VIDEO:
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 8b03d3b108..28090423c6 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1042,6 +1042,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
const AVCodec *enc;
AVStream *st;
int ret = 0, keep_pix_fmt = 0;
+ AVRational enc_tb = { 0, 0 };
const char *bsfs = NULL, *time_base = NULL;
char *filters = NULL, *next, *codec_tag = NULL;
double qscale = -1;
@@ -1260,7 +1261,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
#endif
}
- ost->enc_timebase = q;
+ enc_tb = q;
}
} else {
ret = filter_codec_opts(o->g->codec_opts, AV_CODEC_ID_NONE, oc, st,
@@ -1377,6 +1378,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
(type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) {
OutputFilterOptions opts = {
.enc = enc,
+ .output_tb = enc_tb,
.ts_offset = mux->of.start_time == AV_NOPTS_VALUE ?
0 : mux->of.start_time,
.flags = OFILTER_FLAG_DISABLE_CONVERT * !!keep_pix_fmt,