[FFmpeg-devel] [PATCH]Support linebreaks in onCaption subtitles

Clément Bœsch u at pkh.me
Fri May 1 11:30:33 CEST 2015


On Fri, May 01, 2015 at 01:48:34AM +0200, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch improves the samples from ticket #2933.
> 
> Please comment, Carl Eugen

> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index 2552962..9bd69c5 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -500,6 +500,7 @@ void avcodec_register_all(void)
>      REGISTER_DECODER(MICRODVD,          microdvd);
>      REGISTER_ENCDEC (MOVTEXT,           movtext);
>      REGISTER_DECODER(MPL2,              mpl2);
> +    REGISTER_DECODER(ONCAPTION,         oncaption);
>      REGISTER_DECODER(PGSSUB,            pgssub);
>      REGISTER_DECODER(PJS,               pjs);
>      REGISTER_DECODER(REALTEXT,          realtext);
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 8c7c420..be91dcb 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -525,6 +525,7 @@ enum AVCodecID {
>      AV_CODEC_ID_VPLAYER    = MKBETAG('V','P','l','r'),
>      AV_CODEC_ID_PJS        = MKBETAG('P','h','J','S'),
>      AV_CODEC_ID_ASS        = MKBETAG('A','S','S',' '),  ///< ASS as defined in Matroska
> +    AV_CODEC_ID_ONCAPTION  = MKBETAG('o','n','C','a'),
>  
>      /* other specific kind of codecs (generally used for attachments) */
>      AV_CODEC_ID_FIRST_UNKNOWN = 0x18000,           ///< A dummy ID pointing at the start of various fake codecs.
> diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
> index c1694f3..c286a01 100644
> --- a/libavcodec/codec_desc.c
> +++ b/libavcodec/codec_desc.c
> @@ -2705,6 +2705,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
>          .long_name = NULL_IF_CONFIG_SMALL("WebVTT subtitle"),
>          .props     = AV_CODEC_PROP_TEXT_SUB,
>      },
> +    {
> +        .id        = AV_CODEC_ID_ONCAPTION,
> +        .type      = AVMEDIA_TYPE_SUBTITLE,
> +        .name      = "oncaption",
> +        .long_name = NULL_IF_CONFIG_SMALL("OnCaption FLV subtitle"),
> +        .props     = AV_CODEC_PROP_TEXT_SUB,
> +    },
>  
>      /* other kind of codecs and pseudo-codecs */
>      {
> diff --git a/libavcodec/textdec.c b/libavcodec/textdec.c
> index c9f02a2..6b46938 100644
> --- a/libavcodec/textdec.c
> +++ b/libavcodec/textdec.c
> @@ -88,6 +88,29 @@ AVCodec ff_text_decoder = {
>  };
>  #endif
>  
> +#if CONFIG_ONCAPTION_DECODER
> +#define oncaption_options options
> +DECLARE_CLASS(oncaption);
> +
> +static int oncaption_linebreak_init(AVCodecContext *avctx)
> +{
> +    TextContext *text = avctx->priv_data;

> +    text->linebreaks = "<br/>";

i'm afraid this won't be enough to support "<br>", "<BR>", "<br />", ...

[...]

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


More information about the ffmpeg-devel mailing list