summaryrefslogtreecommitdiff
path: root/fftools
diff options
context:
space:
mode:
authorCarl Eugen Hoyos <ceffmpeg@gmail.com>2018-06-06 21:09:38 +0200
committerCarl Eugen Hoyos <ceffmpeg@gmail.com>2018-06-09 21:34:27 +0200
commit5686c4489a017209367c03fbc40011db7134581a (patch)
tree12e9c0157ec3fff0c4f07b54acc23255e211e12d /fftools
parentcf81a9c07891966cca6d3bb31ed6931fae1f77ea (diff)
ffmpeg: Fail if the user requested impossible subtitle encoding.
Fixes ticket #7239.
Diffstat (limited to 'fftools')
-rw-r--r--fftools/ffmpeg.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 10f3012cdc..d4ac6903cc 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3485,6 +3485,23 @@ static int init_output_stream(OutputStream *ost, char *error, int error_len)
return ret;
}
}
+ if (ist && ist->dec->type == AVMEDIA_TYPE_SUBTITLE && ost->enc->type == AVMEDIA_TYPE_SUBTITLE) {
+ int input_props = 0, output_props = 0;
+ AVCodecDescriptor const *input_descriptor =
+ avcodec_descriptor_get(dec->codec_id);
+ AVCodecDescriptor const *output_descriptor =
+ avcodec_descriptor_get(ost->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) {
+ snprintf(error, error_len,
+ "Subtitle encoding currently only possible from text to text "
+ "or bitmap to bitmap");
+ return AVERROR_INVALIDDATA;
+ }
+ }
if ((ret = avcodec_open2(ost->enc_ctx, codec, &ost->encoder_opts)) < 0) {
if (ret == AVERROR_EXPERIMENTAL)