[FFmpeg-cvslog] fftools/ffmpeg: fail earlier on text/bitmap subtitles mismatch
Anton Khirnov
git at videolan.org
Sun May 28 11:52:29 EEST 2023
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Wed May 17 17:20:11 2023 +0200| [ec75b79fe148174fa704e09c7235e1ea9a4c2680] | committer: Anton Khirnov
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.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ec75b79fe148174fa704e09c7235e1ea9a4c2680
---
fftools/ffmpeg_enc.c | 18 ------------------
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);
+ }
}
}
More information about the ffmpeg-cvslog
mailing list