public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [linux-dvb] How to convert MPEG-TS to MPEG-PS on the fly?
@ 2008-08-20 21:10 Josef Wolf
  2008-08-20 21:17 ` Steven Toth
  2008-08-21 19:17 ` Josef Wolf
  0 siblings, 2 replies; 30+ messages in thread
From: Josef Wolf @ 2008-08-20 21:10 UTC (permalink / raw)
  To: linux-dvb

Hello,

I'd like to convert live mpeg-ts streams from DVB-S on the fly into
a mpeg-ps stream.  I know that (for example)

  mencoder -oac copy -ovc copy -of mpeg -quiet infile -o outfile.mpg

can (almost) do what I want.  But I want to do it on the fly for
multiple streams in parallel and without any temporary files.  So I
decided to roll my own implementation.

I started demuxing the TS stream:

- first, I find the PIDs I am interested in (e.g. pids 110,120,121
  for the german ZDF channel on Astra).

- then, I extract all the PES packets from those streams, leaving
  the PES headers intact.  That is, I just snip off the four bytes
  TS header and throw away the adaptation field.

  Since the PES_packet_length for the video stream is zero, I assume
  I need to collect data until the payload_unit_start_indicator
  indicates the start of the next PES packet (ignoring TS header
  and adaptation_field, of course).
  

So, now I have (with the ZDF example) three streams of PES packets:

  -> video packets coming from PID 110
  -> first audio stream coming from PID 120
  -> second audio stream coming from PID 121

Both, mplayer and vlc play the audio streams fine.  But the video
stream gives lots of artefacts (blocks) with vlc.  mplayer completely
refuses to play it with the following message:

  Playing zdf.test.
  libavformat file format detected.
  Seek failed
  LAVF: no audio or video headers found - broken file?

Why that?  Maybe I should strip off the PES headers also to get a
valid ES?  Or is PES not suitable for playback at all?  Or maybe I
should strip off packets with specific Stream_id?  Here is the
sequence of stream_id's contained in the stream:

  jw@dvb1:~$ dvbsnoop -s pes -if zdf.test|grep Stream_id|head -40
  Stream_id: 224 (0xe0)  [= ITU-T Rec. H.262 | ISO/IEC 13818-2 or ISO/IEC 11172-2 video stream]
  Stream_id: 0 (0x00)  [= picture_start_code]
  Stream_id: 181 (0xb5)  [= extension_start_code]
  Stream_id: 1 (0x01)  [= slice_start_code]
  Stream_id: 2 (0x02)  [= slice_start_code]
  [ consecutive lines deleted ]
  Stream_id: 34 (0x22)  [= slice_start_code]
  Stream_id: 35 (0x23)  [= slice_start_code]
  [ here the list of stream ids start over again and repeats ]

Maybe I should discard some of those to get a proper PES?


The next step would be to multiplex the three streams into a PS.
For this, I will have to insert the system_clock_reference_base(SCR).
Is this available somewhere in the PES headers?  Or can I reuse
(recalculate?) the program_clock_reference_base (PCR) from the
adaptation_field?


_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2008-08-29 15:50 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-20 21:10 [linux-dvb] How to convert MPEG-TS to MPEG-PS on the fly? Josef Wolf
2008-08-20 21:17 ` Steven Toth
2008-08-20 21:48   ` Josef Wolf
2008-08-21 12:10     ` barry bouwsma
2008-08-21 17:45       ` Josef Wolf
2008-08-22  1:07         ` Kevin Sheehan
2008-08-22  5:15           ` barry bouwsma
2008-08-22 15:16             ` Josef Wolf
2008-08-22 14:44           ` Josef Wolf
2008-08-22 15:44             ` Nick Ludlam
2008-08-25 19:02               ` Josef Wolf
2008-08-26  6:49                 ` Nico Sabbi
2008-08-26 12:00                   ` barry bouwsma
2008-08-26 22:45                     ` Josef Wolf
2008-08-27  7:26                       ` barry bouwsma
2008-08-27 22:00                         ` Josef Wolf
2008-08-28 14:40                           ` Johannes Stezenbach
2008-08-28 19:34                             ` Josef Wolf
2008-08-28 21:09                               ` Johannes Stezenbach
2008-08-28 22:48                                 ` Josef Wolf
2008-08-29  5:49                                   ` Josef Wolf
2008-08-29 15:45                       ` [linux-dvb] PTS/DTS clarification (Was: How to convert MPEG-TS to MPEG-PS on the fly?) Josef Wolf
2008-08-26 22:31                   ` [linux-dvb] How to convert MPEG-TS to MPEG-PS on the fly? Josef Wolf
2008-08-21 19:17 ` Josef Wolf
2008-08-21 21:14   ` Josef Wolf
2008-08-22  8:10     ` [linux-dvb] RE : " Thierry Lelegard
2008-08-25 19:55       ` Josef Wolf
2008-08-26  6:50         ` Nico Sabbi
2008-08-26 21:19           ` Josef Wolf
2008-08-22  7:57   ` Thierry Lelegard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox