[FFmpeg-devel] [PATCH] mpegts: Write subtitle extradata if set
Tomas Härdin
tomas.hardin
Mon Sep 27 14:28:09 CEST 2010
On Fri, 2010-09-24 at 19:15 -0700, Baptiste Coudurier wrote:
> 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.
Applied.
/Tomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100927/5b3981bf/attachment.pgp>
More information about the ffmpeg-devel
mailing list