6

I am writing a server which live streams mpeg2-ts on HTTP and I wondered what's the best position to split an mpeg transport stream. The stream is going to be played by iptv set-top boxes and I have no idea how these devices behave.

I would think that the best place to start a stream is before an I-Frame, but the device might need the PAT and PMT packets before it starts to decode video stream data...

Karoly Horvath
  • 94,607
  • 11
  • 117
  • 176
  • Did you find any solution?! If TS contain multiple programs (TV programs that captured by DVB-T), how can split it? For example I have a TS file that contain football + cooking + cartoon .How can i split this TS file to 3 mpg files? – Dr.jacky Jul 20 '15 at 12:43
  • I can explain how to do it programmatically (check PAT & rewrite it, grab the appropriate PMT, look for the stream identifiers, extract only the relevant data, .. and you probably have to re-number the packets) - but if all you want to do is to split, you'd better search for a tool (ffmpeg?) – Karoly Horvath Jul 27 '15 at 11:45

2 Answers2

1

To be safe you should use self-initializing TS segments. Such segment must include the PAT/PMT and start with an IDR-frame.

For example this is a requirement in the HTTP Live Streaming pantos draft when using I-Frame playlists.

See more: GPAC - Apple HLS Introduction

Community
  • 1
  • 1
aergistal
  • 29,947
  • 5
  • 70
  • 92
1

You can start with every 188-byte TS packet (0x47 is the start code). The MPEG decoder automatically jumps in at the first I frame. You can do tricks like MS Mediaroom does with sending burst I-frames, but this requires heavy changes to your client (and patent royalities).

frank
  • 11
  • 1
  • Theoretically, yes.. practically I was sometimes able to crash a lame set-top box (which is btw quite popular here) by doing that (no, I don't start at any 0x47, I *know* it's a TS packet start). Also decoder starts before first I-frame so I see some bad decoded frames for half a sec.. – Karoly Horvath Jul 12 '11 at 07:29
  • Some players require self-initialized TS segments, that is segments that start with a PAT/PMT and I-Frame. Eg: Android 4.4.4 player doesn't like it if there's no PAT/PMT and it won't decode at all. – aergistal Apr 10 '15 at 09:19