[linux-dvb] How to convert MPEG-TS to MPEG-PS on the fly?

Nico Sabbi nicola.sabbi at poste.it
Tue Aug 26 08:49:08 CEST 2008


Il giorno lun, 25/08/2008 alle 21.02 +0200, Josef Wolf ha scritto:
> On Fri, Aug 22, 2008 at 04:44:56PM +0100, Nick Ludlam wrote:
> > On 22 Aug 2008, at 15:44, Josef Wolf wrote:
> >>On Fri, Aug 22, 2008 at 11:07:47AM +1000, Kevin Sheehan wrote:
> >>
> >>>Barry was right on the money with the ts2ps suggestion below.  It's  
> >>>part of the libdvb package.  You don't have to use the dvb-mpegtools  
> >>>app, you can just use the lib in yours - no pipes, etc.


dvb-mpegtools, like mplex, demuxes the TS and loses all informations
about timestamps => very likely the output will be out of sync.

> 
> I have now changed my application to create exactly what ts2ps creates.
> Now I notice that neither mplayer nor vlc play the stream created by
> ts2ps.


I'v eseen ts2ps make a real mess in countless occasions, especially 
with broken TSs.

> 
> Vlc gives tons of error messages like this:
> 
>   [00000365] main video output warning: vout warning: early picture skipped (47722279483)
>   [00000359] main audio output warning: received buffer in the future (47722179597)
> 
> no audio and black video :-(
> 
> If I remove the PS pack header and the PS system header (stream-id 0xba
> and 0xbb) then both play the stream, but no STB plays it :-(


You must have corrupted some header in your application :)

> 
> Next, I tried:
> 
> > The command I wrapped in a popen call from a script was:
> > 
> > 	/opt/local/bin/replex -o /dev/stdout -i TS -v %s -a %s -t MPEG2 
> > 	/dev/ stdin
> 
> With this command, I get hopping video with VLC.


replex never worked with at least 60% of the TSs I fed it with,
that left me no other choise than to fix mencoder's muxer, as long
as something as horribly crippled and broken like mencoder can be
fixed (that may not work if you give it 100% correct timestamps
for every single frame)

> 
> It seems to be a mess.  None of the programs seem to produce proper
> streams.  Only mencoder seems to generate a proper stream.  But AFAICS,
> mencoder completely decodes the stream and re-encodes it again, eating
> up all the CPU.

it doesn't decode: it just demuxes, although parsing audio and video
frame headers is probably eating up a good % of your cpu.
If you want to make it lighter either
- use ffmpeg, it can be surely used to generate many PS from a single TS
  although its command line is really challenging
- use -demuxer lavf and fix libmpdemux/muxer_mpeg.c so that frames are
  not analyzed within the muxer itself, but just copied verbatim in
  teh corresponding mpeg_frame_t[] array


> 
> Any more ideas how to do the conversion?
> 
> BTW: Can anybody recommend a good book on the topic?
> 

none that I know of, but muxing mpeg-ps is more trivial than it looks
like when reading the specs




More information about the linux-dvb mailing list