aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Thelen <ffmpeg-dev@c-14.de>2015-09-11 21:49:07 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2015-10-08 13:15:42 +0200
commit9bbcd1cc7b19be80e59619a443edead333b8efb9 (patch)
treef23226b1972a847d90d22617e84cee7c0a4be00d
parent9801c9524a93d47f25e41e22cefce7ba0fe4e4ca (diff)
downloadffmpeg-9bbcd1cc7b19be80e59619a443edead333b8efb9.tar.gz
lavf/webvttenc: Require webvtt file to contain exactly one WebVTT stream.
Not requiring this can end up producing hilariously broken files together with -c:s copy (e.g. a webvtt file containing binary subtitle data). Signed-off-by: Simon Thelen <ffmpeg-dev@c-14.de> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit b84232694ef0c6897e82b52326c9ea4027c69ec4) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/webvttenc.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libavformat/webvttenc.c b/libavformat/webvttenc.c
index b93993d55c..c386538718 100644
--- a/libavformat/webvttenc.c
+++ b/libavformat/webvttenc.c
@@ -46,8 +46,14 @@ static void webvtt_write_time(AVIOContext *pb, int64_t millisec)
static int webvtt_write_header(AVFormatContext *ctx)
{
AVStream *s = ctx->streams[0];
+ AVCodecContext *avctx = ctx->streams[0]->codec;
AVIOContext *pb = ctx->pb;
+ if (ctx->nb_streams != 1 || avctx->codec_id != AV_CODEC_ID_WEBVTT) {
+ av_log(ctx, AV_LOG_ERROR, "Exactly one WebVTT stream is needed.\n");
+ return AVERROR(EINVAL);
+ }
+
avpriv_set_pts_info(s, 64, 1, 1000);
avio_printf(pb, "WEBVTT\n");