mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-26 19:01:44 +02:00
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.
This commit is contained in:
parent
2b3905254e
commit
ec75b79fe1
@ -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:
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user