[mythtv] DVB subtitles and TS->PES decoder

Marcus Metzler mocm at mocm.de
Thu Nov 25 09:13:20 UTC 2004


>>>>> "Juha" == Juha Kuikka <juha.kuikka at gmail.com> writes:

    Juha> Hi, I am in the process of writing DVB subtiele parser, it
    Juha> is nowhere near ready but I looked at how to best integrate
    Juha> it into myth.

    Juha> First problem I run into is that hte current ts->pes parser
    Juha> in transform.c does not seem to parse subtitle streams, at
    Juha> least I cannot get it to output video, audio and subtitle
    Juha> streams, it seems to ignore the subtitle stream. Does anyone
    Juha> know if this is possible at all or should I just use my own
    Juha> ts->pes parser and replace the one in transform.c ?

It's possible.

    Juha> Concerning this replacement: It seems that DVB TS video
    Juha> stream contains PES packets that have no size field (it is
    Juha> set to zero). This is allowed in TS contained PES stream but
    Juha> if we want to store PES stream in file this has to be
    Juha> corrected. Transform.c:s parser seems to split these long
    Juha> PES packets into smaller ones.

    Juha> I have not yet looked closely at how transfor.c does this
    Juha> but I fear it is not as simple as cutting the packet info
    Juha> nice pieces and assembling those into smaller pes
    Juha> packets. One problem might be the PTS's in the PES headers,
    Juha> I suspect those will have to be correctly regenerated or it
    Juha> may cause synch problems.

No it won't. The PTS is only meaningful at the beginning of a frame
and that is just where the PES begins in the TS. The video PES in a TS
are usually one frame long which can be longer than 65536 bytes and
therfore the length 0 is allowed. If you cut up those PES into smaller
pieces you only put the PTS on the first piece where it belongs. All
other pieces don't have a PTS. The only problem with the process is
muxing, but this is usually only a problem when your ES buffers are
limited. I don't know how large they are for mythtv.

    Juha> Does anyone have deeper knowledge about this? Spec might be
    Juha> nice?

AFAIKT the TS to PES conversion uses my routines from the
dvb-mpegtools package. This is good enough for a quick and dirty
transformation, but can not be used for e.g. authoring DVDs where you
have to get the muxing correct and add some more time stamps. That's
why I started dvb-replex (see http://www.metzlerbros.org/dvb/index.html)

    Juha> What is inside these video streams PES packets? Do I have to
    Juha> parse those too to make the split correctly?

    Juha> "Easy" solution might be to hack up transform.c to accept
    Juha> more than two streams but I suspect that is not very easy as
    Juha> the HDTVRecorder people seem not to have done this.



That should not be too hard. For every PID you need to set up an
instant repack structure, like      init_ipack(&pa, IPACKS,write_out,
ps);
where pa is a pointer to an ipack structure, IPACKS is the size of the
PES that should come out and write out is the function that gets the
cut up PES for writing. Then you feed the function
instant_repack(buf+4+off+i, TS_SIZE-4-off, p); with the payload of the
appropriate TS packets and the pointer (p) to the ipack structure.

Right now instant_repack only handles video and audio PES (i.e. 0xe0 -
0xef and 0xc0-0xdf ids) as well as private stream 1 PES with AC3 payload.
This is checked for in instant_repack and in write_ipack.

If you tell me what you would like to have I can put it in the
routines.
There are also routines in libdvb that handle video/teletext decoding,
There is an example application in the sample_progs directory of
libdvb, that shows how to use the videotext routines (cam_test.c).

Marcus

-- 
/--------------------------------------------------------------------\
| Dr. Marcus O.C. Metzler        |                                   |
| mocm at metzlerbros.de            | http://www.metzlerbros.de/        |
\--------------------------------------------------------------------/
 |>>>             Quis custodiet ipsos custodies                 <<<|


More information about the mythtv-dev mailing list