aboutsummaryrefslogtreecommitdiffstats
path: root/fftools
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-04-18 11:10:08 +0200
committerAnton Khirnov <anton@khirnov.net>2023-04-24 16:56:06 +0200
commit6cace17b0d195a5637bcfba690aab8708a946b5d (patch)
treeba46437da2bf5121494d2231ffb6d37e7afeb861 /fftools
parentab0d2052a3cfd14b616d1944fe11b66aab8ce2f8 (diff)
downloadffmpeg-6cace17b0d195a5637bcfba690aab8708a946b5d.tar.gz
fftools/ffmpeg_mux_init: drop useless new_stream_{data,unknown}
Their only function is checking that encoding was not specified for data/unknown-type streams, but the check is broken because enc_ctx will not be created in ost_add() unless a valid encoder can be found. Add an actually working check for all types for which encoding is not supported in choose_encoder().
Diffstat (limited to 'fftools')
-rw-r--r--fftools/ffmpeg_mux_init.c38
1 files changed, 15 insertions, 23 deletions
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 59d9a12c1a..28254cb49b 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -113,8 +113,21 @@ static int choose_encoder(const OptionsContext *o, AVFormatContext *s,
*enc = NULL;
- if (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO || type == AVMEDIA_TYPE_SUBTITLE) {
- MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, ost->st);
+ MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, ost->st);
+
+ if (type != AVMEDIA_TYPE_VIDEO &&
+ type != AVMEDIA_TYPE_AUDIO &&
+ type != AVMEDIA_TYPE_SUBTITLE) {
+ if (codec_name && strcmp(codec_name, "copy")) {
+ const char *type_str = av_get_media_type_string(type);
+ av_log(ost, AV_LOG_FATAL,
+ "Encoder '%s' specified, but only '-codec copy' supported "
+ "for %s streams\n", codec_name, type_str);
+ return AVERROR(ENOSYS);
+ }
+ return 0;
+ }
+
if (!codec_name) {
ost->par_in->codec_id = av_guess_codec(s->oformat, NULL, s->url,
NULL, ost->type);
@@ -130,7 +143,6 @@ static int choose_encoder(const OptionsContext *o, AVFormatContext *s,
*enc = find_codec_or_die(ost, codec_name, ost->type, 1);
ost->par_in->codec_id = (*enc)->id;
}
- }
return 0;
}
@@ -796,24 +808,6 @@ static void new_stream_audio(Muxer *mux, const OptionsContext *o,
}
}
-static void new_stream_data(Muxer *mux, const OptionsContext *o,
- OutputStream *ost)
-{
- if (ost->enc_ctx) {
- av_log(ost, AV_LOG_FATAL, "Data stream encoding not supported yet (only streamcopy)\n");
- exit_program(1);
- }
-}
-
-static void new_stream_unknown(Muxer *mux, const OptionsContext *o,
- OutputStream *ost)
-{
- if (ost->enc_ctx) {
- av_log(ost, AV_LOG_FATAL, "Unknown stream encoding not supported yet (only streamcopy)\n");
- exit_program(1);
- }
-}
-
static void new_stream_attachment(Muxer *mux, const OptionsContext *o,
OutputStream *ost)
{
@@ -1218,9 +1212,7 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o,
case AVMEDIA_TYPE_VIDEO: new_stream_video (mux, o, ost); break;
case AVMEDIA_TYPE_AUDIO: new_stream_audio (mux, o, ost); break;
case AVMEDIA_TYPE_SUBTITLE: new_stream_subtitle (mux, o, ost); break;
- case AVMEDIA_TYPE_DATA: new_stream_data (mux, o, ost); break;
case AVMEDIA_TYPE_ATTACHMENT: new_stream_attachment(mux, o, ost); break;
- default: new_stream_unknown (mux, o, ost); break;
}
if (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO) {