[FFmpeg-devel] [PATCH] mpegts: Write subtitle extradata if set

Baptiste Coudurier baptiste.coudurier
Sat Sep 25 04:15:09 CEST 2010


Hi Tomas,

On 09/24/2010 04:12 AM, Tomas H?rdin wrote:
> Hi
>
> When remuxing mpegts with dvbsub streams no subtitles are output when
> ffplay or vlc decodes the resulting file. I've tracked this down to two
> causes:
>
> 1. The mpegts muxer doesn't write the subtitle stream's extradata
> (compare mpegts.c:987 and mpegtsenc.c:279). Instead it makes up its own
> data, which then causes the dvbsub decoder to do nothing since page_id
> matches neither composition_id nor ancillary_id
>
> 2. dvbsub_parser strips a few bytes off the subtitle data. These bytes
> need to be put back in before the packets are muxed, presumably using a
> bitstream filter
>
> I thought I'd post the first fix on that list while I work on the second
> part. The fix is simple: if the muxer has exactly 4 B extradata for the
> subtitle stream then write it.
>
> Patch attached, passed regtests. Also attached indentation patch. I
> could upload a sample if you wish. I didn't yet because the patch is
> quite trivial.
>
> /Tomas
>
>
> mpegts_sub_extradata.patch
>
>
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index ac09ab9..94a051d 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> @@ -276,8 +276,13 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
>                   *q++ = language[1];
>                   *q++ = language[2];
>                   *q++ = 0x10; /* normal subtitles (0x20 = if hearing pb) */
> +                if(st->codec->extradata_size == 4) {
> +                    memcpy(q, st->codec->extradata, 4);
> +                    q += 4;
> +                } else {
>                   put16(&q, 1); /* page id */
>                   put16(&q, 1); /* ancillary page id */
> +                }
>               }
>               break;
>           case AVMEDIA_TYPE_VIDEO:
>
>
> mpegts_sub_extradata_indent.patch
>
>
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index 94a051d..2d1fd40 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> @@ -280,8 +280,8 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
>                       memcpy(q, st->codec->extradata, 4);
>                       q += 4;
>                   } else {
> -                put16(&q, 1); /* page id */
> -                put16(&q, 1); /* ancillary page id */
> +                    put16(&q, 1); /* page id */
> +                    put16(&q, 1); /* ancillary page id */
>                   }
>               }
>               break;
>

Both patches ok, btw I believe the dvbsub_parser is not needed anymore 
since now the demuxer outputs full PES packets.

-- 
Baptiste COUDURIER
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer                                  http://www.ffmpeg.org



More information about the ffmpeg-devel mailing list