]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/webvttenc.c
lavf/webvttenc: Require webvtt file to contain exactly one WebVTT stream.
[ffmpeg] / libavformat / webvttenc.c
index b93993d55ce2a8e7f4c8a70725de396db9441ed3..c38653871862d997fd09244b2c83952fb214fb21 100644 (file)
@@ -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");