diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-05-17 17:20:11 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-05-28 10:47:59 +0200 |
commit | ec75b79fe148174fa704e09c7235e1ea9a4c2680 (patch) | |
tree | 6077828540e6dff86d43525643e3e7a4b445cba9 | |
parent | 2b3905254ea1a38532278c38d2fe1b5f16ca95b9 (diff) | |
download | ffmpeg-ec75b79fe148174fa704e09c7235e1ea9a4c2680.tar.gz |
fftools/ffmpeg: fail earlier on text/bitmap subtitles mismatch
Checking whether the user requested an unsupported conversion between
text and bitmap subtitles can be done immediately when creating the
output stream.
-rw-r--r-- | fftools/ffmpeg_enc.c | 18 | ||||
-rw-r--r-- | fftools/ffmpeg_mux_init.c | 17 |
2 files changed, 17 insertions, 18 deletions
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 59e9466420..f023657a07 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -345,24 +345,6 @@ int enc_open(OutputStream *ost, AVFrame *frame) dec_ctx->subtitle_header_size); enc_ctx->subtitle_header_size = dec_ctx->subtitle_header_size; } - if (ist && ist->dec->type == AVMEDIA_TYPE_SUBTITLE && - enc_ctx->codec_type == AVMEDIA_TYPE_SUBTITLE) { - int input_props = 0, output_props = 0; - AVCodecDescriptor const *input_descriptor = - avcodec_descriptor_get(ist->dec->id); - AVCodecDescriptor const *output_descriptor = - avcodec_descriptor_get(enc_ctx->codec_id); - if (input_descriptor) - input_props = input_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB); - if (output_descriptor) - output_props = output_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB); - if (input_props && output_props && input_props != output_props) { - av_log(ost, AV_LOG_ERROR, - "Subtitle encoding currently only possible from text to text " - "or bitmap to bitmap"); - return AVERROR_INVALIDDATA; - } - } break; default: diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index b73791acee..56f9d1215c 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -822,6 +822,13 @@ static void new_stream_subtitle(Muxer *mux, const OptionsContext *o, if (ost->enc_ctx) { AVCodecContext *subtitle_enc = ost->enc_ctx; + + AVCodecDescriptor const *input_descriptor = + avcodec_descriptor_get(ost->ist->par->codec_id); + AVCodecDescriptor const *output_descriptor = + avcodec_descriptor_get(subtitle_enc->codec_id); + int input_props = 0, output_props = 0; + char *frame_size = NULL; MATCH_PER_STREAM_OPT(frame_sizes, str, frame_size, mux->fc, st); @@ -829,6 +836,16 @@ static void new_stream_subtitle(Muxer *mux, const OptionsContext *o, av_log(ost, AV_LOG_FATAL, "Invalid frame size: %s.\n", frame_size); exit_program(1); } + if (input_descriptor) + input_props = input_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB); + if (output_descriptor) + output_props = output_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB); + if (input_props && output_props && input_props != output_props) { + av_log(ost, AV_LOG_ERROR, + "Subtitle encoding currently only possible from text to text " + "or bitmap to bitmap\n"); + exit_program(1); + } } } |