[FFmpeg-devel] [FFmpeg-user] BUG in use of extradata and extradata_size with dvb subtitles and teletext

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun Dec 29 09:25:26 CET 2013


On Sun, Dec 29, 2013 at 12:59:37AM +0000, JULIAN GARDNER wrote:
> ----- Original Message -----
> > From: Clément Bœsch <u at pkh.me>
> > To: FFmpeg development discussions and patches <ffmpeg-devel at ffmpeg.org>
> > Cc: 
> > Sent: Sunday, 29 December 2013, 1:36
> > Subject: Re: [FFmpeg-devel] [FFmpeg-user] BUG in use of extradata and extradata_size with dvb subtitles and teletext
> > 
> > On Sat, Dec 28, 2013 at 10:11:56PM +0000, JULIAN GARDNER wrote:
> >>  >>OK, ive posted this here as requested,
> >> 
> >>  >>
> >>  >>What is needed to get working in order to fix other things
> >>  >>
> >>  >>1. When creating a DVBSUBS encoder stream, need the extradata and 
> > extradata_size to have the associated values from the input source copied across 
> > if dvbsubs, if not dvbsubs then ths needs creating with the defailt values of 
> > 0x0001 0x0001. Pointers please as to where this should be done.
> >>  >>
> >>  >>2. The timeout value from the incoming dvbsubs needs to be taken 
> > into account in the ffmpeg transcode loop so if this expires a new subtitle 
> > packet is created with 0 objects, in essence a clear screen, BUT only when the 
> > timer expires
> >>  >>
> >>  >>joolz
> >>  >
> >>  >
> >>  >Can someone point me to the area i should be looking so i can fix one 
> > of the dvbsubs bugs.
> >>  >
> >>  >The problem is as follows
> >>  >
> >> 
> >> mpegts->dvbsubs->(composition_page_Id,ancilllary_page_id)->COPY->dvbsub(0x0001,0x001)->pmt(0x0001,0x001)->mpegts
> >>  >
> >>  >What is happening is we are getting the 2 page_ids correctly but when 
> > we copy the pmt has the defaults 0x0001,0x0001. 
> >>  >
> >>  >Now i see a !osd->stream_copy in new_subtitle_stream in ffmpeg_opt.s 
> > but i cannot/dont know how to find the input that is tied to this so i can copy 
> > across the extradata from the input.
> >>  >
> >>  >Can someone help me on this.
> >>  > 
> >> 
> >> 
> >>  PING
> >> 
> >>  Anybody able to help me on this?
> >> 
> >>  All i need is some example, new code or a place in the current tree that 
> > will allow me to find the source extradata pointer so i can copy over the ids.
> >> 
> > 
> > I have great difficulties trying to figure out what this gibberish is all
> > about, so please excuse if I completely misunderstand your question.
> > 
> > The dvbsub decoder (libavcodec/dvbsubdec.c) is reading from extradata to
> > extract the composition and ancillary id. You seem to be saying that this
> > information is incorrectly set. If you need to update this extradata based
> > on the information in the input stream, the MPEG-TS demuxer
> > (libavformat/mpegts.c) is probably where you need to look (because AFAIK
> > that's the only format supporting DVB sub right now). Try to run git grep
> > 'extradata.*alloc' to see how it's done in other demuxers.
> > 
> > -- 
> 
> Gibberish off for the people at the back, and your wrong in your reading of my simple english gibberish
> 
> OK
> 
> doing a simple pass through, NOT ENCODING
> 
> ffmpeg -i dvbsubs.ts -vcodec copy -acodec copy -scodec copy -f mpegts dvbsout.ts
> 
> Input transport stream contains a dvb subtitle stream which has the page_id set to 0x0002 and ancillary_id set to 0x0002, this is decoded correctly and stored in the memory pointed to by extradata and also extradata_size is set to 4
> 
> This is passed through the ffmpeg chain and excreated out into the ts stream, BUT as the extradata from the input stream IS NOT transferred by the new_subtitle_stream function, see function ffmpeg_opt around 1471 as this specifically checks for it NOT being a stream copy, the extradata for the OUTPUT stream is left as NULL and extradata_size is 0.
> 
> Now look in mpegtsenc.c at the switch statement for AVMEDIA_TYPE_SUBTITLE and see that the code checks for extradata_size being 4, if not the page_id and ancillary_id are set to a default value 0x0001
> 
> So we now have a pmt in the output TS which says to look for page_id and ancillary_id of 0x0001 and a dvb stream in the same ts that has page_id and ancillary_id of 0x0002
> 
> Do you understand the problem now?
> 
> So what is needed is a fix in ffmpeg_opt.c function new_subtitle_stream which finds the input stream that is feeding the output stream, BUT only when copying, and copies the extradata over so that when the mpegtsenc.c code creates its PMT the page_id and ancillary_id are correctly set to what are in the input stream

I _suspect_ that the intention might have been that the page/ancillary
id are _not_ copied in a stream copy but instead newly allocated,
but then the muxer would have to rewrite the stream data and probably
this would not work well at all.
I guess just copying the extradata probably would be an option.
If only the MPEG designers used things like layering instead of having
everything be one messy blob where every part has to know the internals
of all others...


More information about the ffmpeg-devel mailing list