[linux-dvb] How to convert MPEG-TS to MPEG-PS on the fly?
jw at raven.inka.de
Fri Aug 22 16:44:48 CEST 2008
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.
I know. But I still consider ts2ps to be too heavy for my application.
It goes and parses all the PES contents, which eats much CPU.
But at least, ts2pes was very helpful in analyzing the differences in
the stream between what I created and what ts2pes created. Finally, I
have found the problem:
I appears that PES_packet_length==0 is allowed in TS _only_. While
unpacking, the long packet (I have seen up to 100 kbytes) extracted
from the TS needs to be split up into smaller ones. ps2pes splits
into pieces with PES_packet_length==0x7fa and prepends an empty PES
header (with only the length specification) to each of the new packets.
Finally, I can generate a PES stream with one video and multiple
audio streams which is played pretty fine by mplayer and vlc.
Now I need to add the PS pack header (ts2ps adds 14 bytes) and the
system header (ts2ps adds 18 bytes). For this, I have two more
1. Is the system_header required at all? Table 2-33 in iso-13818-1
seems to make it optional.
2. For creating the PS pack header, the only missing information is
the program_mux_rate. How is this value calculated? How accurate
has this value to be? If the stream bit rate changes (maybe because
of changes in resolution), do I need to adopt this value and generate
a MPEG_program_end_code and add a new pack header with the new
value? Or will the player stop when it detects MPEG_program_end_code?
More information about the linux-dvb