fftools/ffmpeg_filter: pass enc_timebase through OutputFilterOptions

Reduces the need to access OutputStream, which will allow decoupling
filtering from encoding in future commits.
This commit is contained in:
Anton Khirnov 2024-04-01 06:29:16 +02:00
parent 606c71bb11
commit 9d5bf2d69e
3 changed files with 9 additions and 4 deletions

View File

@ -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;

View File

@ -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:

View File

@ -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,