aboutsummaryrefslogtreecommitdiffstats
path: root/fftools
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2024-09-24 10:36:29 +0200
committerAnton Khirnov <anton@khirnov.net>2024-09-30 09:29:18 +0200
commit71916aa1078e0cf3fcdd426756b38f30473b7de7 (patch)
tree5ebbd8c26c679ab0d81d5468a1e9bd86d47f8258 /fftools
parente83b5b2cc8b2fb6eb38f0b3feaecb1631bbaaf83 (diff)
downloadffmpeg-71916aa1078e0cf3fcdd426756b38f30473b7de7.tar.gz
fftools/ffmpeg_mux_init: move the check for filtering+streamcopy
To streamcopy_init(). This will allow to simplify the control flow in ost_add() by moving the ost_get_filters() call (which previously had to handle both encoding and streamcopy streams) to ost_bind_filter() (which is only called for audio/video encoding). Also, return EINVAL rather than ENOSYS, as trying to combine filtering with streamcopy is a parameter error.
Diffstat (limited to 'fftools')
-rw-r--r--fftools/ffmpeg_mux_init.c52
1 files changed, 29 insertions, 23 deletions
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 117b1a4338..1ddd1d7492 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -424,27 +424,6 @@ static int ost_get_filters(const OptionsContext *o, AVFormatContext *oc,
#endif
opt_match_per_stream_str(ost, &o->filters, oc, ost->st, &filters);
- if (!ost->enc) {
- if (
-#if FFMPEG_OPT_FILTER_SCRIPT
- filters_script ||
-#endif
- filters) {
- av_log(ost, AV_LOG_ERROR,
- "%s '%s' was specified, but codec copy was selected. "
- "Filtering and streamcopy cannot be used together.\n",
-#if FFMPEG_OPT_FILTER_SCRIPT
- filters ? "Filtergraph" : "Filtergraph script",
- filters ? filters : filters_script
-#else
- "Filtergraph", filters
-#endif
- );
- return AVERROR(ENOSYS);
- }
- return 0;
- }
-
if (!ost->ist) {
if (
#if FFMPEG_OPT_FILTER_SCRIPT
@@ -1028,7 +1007,8 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter,
return ret;
}
-static int streamcopy_init(const Muxer *mux, OutputStream *ost, AVDictionary **encoder_opts)
+static int streamcopy_init(const OptionsContext *o, const Muxer *mux,
+ OutputStream *ost, AVDictionary **encoder_opts)
{
MuxStream *ms = ms_from_ost(ost);
@@ -1044,6 +1024,32 @@ static int streamcopy_init(const Muxer *mux, OutputStream *ost, AVDictionary **e
int ret = 0;
+ const char *filters = NULL;
+#if FFMPEG_OPT_FILTER_SCRIPT
+ const char *filters_script = NULL;
+
+ opt_match_per_stream_str(ost, &o->filter_scripts, mux->fc, ost->st, &filters_script);
+#endif
+ opt_match_per_stream_str(ost, &o->filters, mux->fc, ost->st, &filters);
+
+ if (
+#if FFMPEG_OPT_FILTER_SCRIPT
+ filters_script ||
+#endif
+ filters) {
+ av_log(ost, AV_LOG_ERROR,
+ "%s '%s' was specified, but codec copy was selected. "
+ "Filtering and streamcopy cannot be used together.\n",
+#if FFMPEG_OPT_FILTER_SCRIPT
+ filters ? "Filtergraph" : "Filtergraph script",
+ filters ? filters : filters_script
+#else
+ "Filtergraph", filters
+#endif
+ );
+ return AVERROR(EINVAL);
+ }
+
codec_ctx = avcodec_alloc_context3(NULL);
if (!codec_ctx)
return AVERROR(ENOMEM);
@@ -1562,7 +1568,7 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
}
if (ost->ist && !ost->enc) {
- ret = streamcopy_init(mux, ost, &encoder_opts);
+ ret = streamcopy_init(o, mux, ost, &encoder_opts);
if (ret < 0)
goto fail;
}