[FFmpeg-devel] [PATCH] Add SUP (raw BluRay PGS subtitle) muxer

Hendrik Leppkes h.leppkes at gmail.com
Thu Sep 4 10:19:05 CEST 2014


On Fri, Aug 29, 2014 at 12:31 PM, Petri Hintukainen <phintuka at gmail.com> wrote:
> From: Petri Hintukainen <phintuka at users.sourceforge.net>
>
> Fixes ticket #2208
> ---
>  libavformat/Makefile     |  1 +
>  libavformat/allformats.c |  1 +
>  libavformat/supenc.c     | 61 ++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 63 insertions(+)
>  create mode 100644 libavformat/supenc.c
>
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 3d124fb..e3cc653 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -405,6 +405,7 @@ OBJS-$(CONFIG_SRT_MUXER)                 += srtenc.o
>  OBJS-$(CONFIG_STR_DEMUXER)               += psxstr.o
>  OBJS-$(CONFIG_SUBVIEWER1_DEMUXER)        += subviewer1dec.o subtitles.o
>  OBJS-$(CONFIG_SUBVIEWER_DEMUXER)         += subviewerdec.o subtitles.o
> +OBJS-$(CONFIG_SUP_MUXER)                 += supenc.o
>  OBJS-$(CONFIG_SWF_DEMUXER)               += swfdec.o swf.o
>  OBJS-$(CONFIG_SWF_MUXER)                 += swfenc.o swf.o
>  OBJS-$(CONFIG_TAK_DEMUXER)               += takdec.o apetag.o img2.o rawdec.o
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index 8f70c4b..a1a55f7 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -280,6 +280,7 @@ void av_register_all(void)
>      REGISTER_DEMUXER (STR,              str);
>      REGISTER_DEMUXER (SUBVIEWER1,       subviewer1);
>      REGISTER_DEMUXER (SUBVIEWER,        subviewer);
> +    REGISTER_MUXER   (SUP,              sup);
>      REGISTER_MUXDEMUX(SWF,              swf);
>      REGISTER_DEMUXER (TAK,              tak);
>      REGISTER_MUXER   (TEE,              tee);
> diff --git a/libavformat/supenc.c b/libavformat/supenc.c
> new file mode 100644
> index 0000000..3447f76
> --- /dev/null
> +++ b/libavformat/supenc.c
> @@ -0,0 +1,61 @@
> +/*
> + * SUP muxer
> + * Copyright (c) 2014 Petri Hintukainen <phintuka at users.sourceforge.net>
> + *
> + * 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 "avformat.h"
> +#include "internal.h"
> +
> +
> +#define SUP_PGS_MAGIC 0x5047 /* "PG", big endian */
> +
> +static int sup_write_packet(AVFormatContext *s, AVPacket *pkt)
> +{
> +    /* header */
> +    avio_wb16(s->pb, SUP_PGS_MAGIC);
> +    avio_wb32(s->pb, (uint64_t)pkt->pts);
> +    avio_wb32(s->pb, (uint64_t)pkt->dts);
> +

All the timestamp talk in the demuxer thread made me think about this part.
What if no dts or pts is set (ie. its AV_NOPTS_VALUE), I doubt writing
that as-is is going to fly over well with other tools (especially
because its value is > 32-bit anyway)

Should you write 0? Should you write dts=pts if only pts is set, and
dts is unset?

- Hendrik


More information about the ffmpeg-devel mailing list