[FFmpeg-devel] [PATCH 2/2] Use private option to specify WebVTT kind

Clément Bœsch ubitux at gmail.com
Tue Jun 25 00:15:49 CEST 2013


On Mon, Jun 24, 2013 at 11:20:32AM -0700, Matthew Heaney wrote:
> WebVTT subtitle tracks have four kinds. Certain downstream muxers
> (such as for WebM) need to know which WebVTT kind this is, in order to
> specify the codec id of the output track.
> 
> A new private input option, "-kind", has been added to the WebVTT
> demuxer.  It accepts as a value any of "subtitles" (the default),
> "captions", "descriptions", and "metadata".  The kind option value is
> used to assign a value to the stream disposition flag, to which four
> new values have been added, corresponding the four WebVTT kinds.
> ---
>  libavformat/webvttdec.c | 34 ++++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 

Applied with the following changes:

> diff --git a/libavformat/webvttdec.c b/libavformat/webvttdec.c
> index 7d9910b..cae5243 100644
> --- a/libavformat/webvttdec.c
> +++ b/libavformat/webvttdec.c
> @@ -29,9 +29,12 @@
>  #include "subtitles.h"
>  #include "libavutil/bprint.h"
>  #include "libavutil/intreadwrite.h"
> +#include "libavutil/opt.h"
>  
>  typedef struct {
> +    const AVClass *class;
>      FFDemuxSubtitlesQueue q;

> +    int64_t kind;

int64_t → int

>  } WebVTTContext;
>  
>  static int webvtt_probe(AVProbeData *p)
> @@ -66,6 +69,7 @@ static int webvtt_read_header(AVFormatContext *s)
>      avpriv_set_pts_info(st, 64, 1, 1000);
>      st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
>      st->codec->codec_id   = AV_CODEC_ID_WEBVTT;
> +    st->disposition |= webvtt->kind;
>  
>      av_bprint_init(&header, 0, AV_BPRINT_SIZE_UNLIMITED);
>      av_bprint_init(&cue,    0, AV_BPRINT_SIZE_UNLIMITED);
> @@ -186,6 +190,35 @@ static int webvtt_read_close(AVFormatContext *s)
>      return 0;
>  }
>  
> +#define OFFSET(x) offsetof(WebVTTContext, x)
> +#define KIND_FLAGS AV_OPT_FLAG_SUBTITLE_PARAM
> +
> +static const AVOption options[] = {
> +    { "kind", "Kind of WebVTT track",
> +      OFFSET(kind), AV_OPT_TYPE_INT, { .i64 = 0 },
> +      0, INT_MAX, KIND_FLAGS, "WEBVTT_KIND" },
> +    { "subtitles", "WebVTT subtitles kind",
> +      0, AV_OPT_TYPE_CONST, { .i64 = 0 },
> +      INT_MIN, INT_MAX, 0, "WEBVTT_KIND" },
> +    { "captions", "WebVTT captions kind",
> +      0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CAPTIONS },
> +      INT_MIN, INT_MAX, 0, "WEBVTT_KIND" },
> +    { "descriptions", "WebVTT descriptions kind",
> +      0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DESCRIPTIONS },
> +      INT_MIN, INT_MAX, 0, "WEBVTT_KIND" },
> +    { "metadata", "WebVTT metadata kind",
> +      0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_METADATA },
> +      INT_MIN, INT_MAX, 0, "WEBVTT_KIND" },
> +    { NULL }

misc cosmetics here

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130625/dd3b07ec/attachment.asc>


More information about the ffmpeg-devel mailing list