diff options
author | Anton Khirnov <anton@khirnov.net> | 2022-10-13 15:39:47 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2022-10-18 13:57:43 +0200 |
commit | 9f9bf8703b919dad486cb3a009eba5db6fa756a9 (patch) | |
tree | 3c826d709f78d741bd84eac1ac7faa5918235074 /fftools/ffmpeg_mux.c | |
parent | ee0a900e5817148c8343f8f95e7b811b069704f4 (diff) | |
download | ffmpeg-9f9bf8703b919dad486cb3a009eba5db6fa756a9.tar.gz |
fftools/ffmpeg: move init_output_bsfs() to ffmpeg_mux
Bitstream filtering is done as a part of muxing, so this is the more
proper place for this.
Diffstat (limited to 'fftools/ffmpeg_mux.c')
-rw-r--r-- | fftools/ffmpeg_mux.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 652628185e..5418cd3000 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -536,12 +536,50 @@ int mux_check_init(Muxer *mux) return 0; } +static int bsf_init(OutputStream *ost) +{ + AVBSFContext *ctx = ost->bsf_ctx; + int ret; + + if (!ctx) + return 0; + + ret = avcodec_parameters_copy(ctx->par_in, ost->st->codecpar); + if (ret < 0) + return ret; + + ctx->time_base_in = ost->st->time_base; + + ret = av_bsf_init(ctx); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Error initializing bitstream filter: %s\n", + ctx->filter->name); + return ret; + } + + ret = avcodec_parameters_copy(ost->st->codecpar, ctx->par_out); + if (ret < 0) + return ret; + ost->st->time_base = ctx->time_base_out; + + return 0; +} + int of_stream_init(OutputFile *of, OutputStream *ost) { Muxer *mux = mux_from_of(of); + int ret; + if (ost->sq_idx_mux >= 0) sq_set_tb(mux->sq_mux, ost->sq_idx_mux, ost->mux_timebase); + /* initialize bitstream filters for the output stream + * needs to be done here, because the codec id for streamcopy is not + * known until now */ + ret = bsf_init(ost); + if (ret < 0) + return ret; + ost->initialized = 1; return mux_check_init(mux); |