Browse Source

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 b84232694e)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
tags/n2.8.1
Simon Thelen Michael Niedermayer 10 years ago
parent
commit
9bbcd1cc7b
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      libavformat/webvttenc.c

+ 6
- 0
libavformat/webvttenc.c View 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");


Loading…
Cancel
Save