[FFmpeg-cvslog] fftools/ffmpeg_filter: pass enc_timebase through OutputFilterOptions

Anton Khirnov git at videolan.org
Tue Apr 9 11:54:21 EEST 2024


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Mon Apr  1 06:29:16 2024 +0200| [9d5bf2d69e6ad85adbf8a673929192e0b07bc080] | committer: Anton Khirnov

fftools/ffmpeg_filter: pass enc_timebase through OutputFilterOptions

Reduces the need to access OutputStream, which will allow decoupling
filtering from encoding in future commits.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9d5bf2d69e6ad85adbf8a673929192e0b07bc080
---

 fftools/ffmpeg.h          | 7 +++++--
 fftools/ffmpeg_filter.c   | 2 +-
 fftools/ffmpeg_mux_init.c | 4 +++-
 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,



More information about the ffmpeg-cvslog mailing list