[FFmpeg-devel] [PATCH] lavf: JSON captions demuxer.

Clément Bœsch ubitux at gmail.com
Fri Jun 22 23:45:28 CEST 2012


On Thu, Jun 21, 2012 at 07:19:55PM +0200, Nicolas George wrote:
> 
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
>  libavformat/Makefile          |    1 +
>  libavformat/allformats.c      |    1 +
>  libavformat/jsoncaptionsdec.c |  350 +++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 352 insertions(+)
>  create mode 100644 libavformat/jsoncaptionsdec.c
> 
> 
> Uses Clément's helper functions (and because of that currently inserts bogus
> \0 at the end of the lines).
> 
> 
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 0060296..f411af5 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -138,6 +138,7 @@ OBJS-$(CONFIG_IVF_DEMUXER)               += ivfdec.o
>  OBJS-$(CONFIG_IVF_MUXER)                 += ivfenc.o
>  OBJS-$(CONFIG_JACOSUB_DEMUXER)           += jacosubdec.o
>  OBJS-$(CONFIG_JACOSUB_MUXER)             += jacosubenc.o rawenc.o
> +OBJS-$(CONFIG_JSONCAPTIONS_DEMUXER)      += jsoncaptionsdec.o
>  OBJS-$(CONFIG_JV_DEMUXER)                += jvdec.o
>  OBJS-$(CONFIG_LATM_DEMUXER)              += rawdec.o
>  OBJS-$(CONFIG_LATM_MUXER)                += latmenc.o rawenc.o
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index c3b8bb4..449a715 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -127,6 +127,7 @@ void av_register_all(void)
>      REGISTER_DEMUXER  (IV8, iv8);
>      REGISTER_MUXDEMUX (IVF, ivf);
>      REGISTER_MUXDEMUX (JACOSUB, jacosub);
> +    REGISTER_DEMUXER  (JSONCAPTIONS, jsoncaptions);
>      REGISTER_DEMUXER  (JV, jv);
>      REGISTER_MUXDEMUX (LATM, latm);
>      REGISTER_DEMUXER  (LMLM4, lmlm4);
> diff --git a/libavformat/jsoncaptionsdec.c b/libavformat/jsoncaptionsdec.c
> new file mode 100644
> index 0000000..a5fe8ac
> --- /dev/null
> +++ b/libavformat/jsoncaptionsdec.c
> @@ -0,0 +1,350 @@
> +/*
> + * JSON captions format decoder
> + * Copyright (c) 2012 Nicolas George
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#include "libavutil/bprint.h"
> +#include "libavutil/log.h"
> +#include "libavutil/opt.h"
> +#include "avformat.h"
> +#include "internal.h"
> +#include "subtitles.h"
> +
> +struct json_captions_demuxer {

You really don't like typedef struct aren't you? :-)

I can blame you, though we try keep some consistency…

> +    AVClass *class;
> +    int64_t start_time;
> +    FFDemuxSubtitlesQueue subs;

nit: I used 'q' in the other demuxers, but maybe you don't like it as
well… :-)

[...]
> +AVInputFormat ff_jsoncaptions_demuxer = {
> +    .name           = "json_captions",
> +    .long_name      = NULL_IF_CONFIG_SMALL("JSON captions (used in TED talks)"),

I'll review this properly after my patchset with FFDemuxSubtitlesQueue is
upstream, but it looks nice at a first glance. Can you provide a random
sample & test for fate (covering UTF-8 stuff would be nice)?

BTW, did you see if that format is use somewhere else than TED? If not,
maybe it would be wise to name it differently. Or maybe there are some
public specs somewhere?

Also, I suppose the start_time is to skip TED opening?

Last thing: all the languages are in different files, right (so you don't
have a format with multiple possible streams)?

-- 
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/20120622/9ac6d451/attachment.asc>


More information about the ffmpeg-devel mailing list