where to start/split mpeg2-ts
Asked Answered
H

2

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...

Hypostyle answered 16/6, 2011 at 16:26 Comment(2)
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?Rheumy
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?)Hypostyle
L
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).

Loden answered 12/7, 2011 at 7:1 Comment(2)
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..Hypostyle
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.Extraditable
E
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

Extraditable answered 10/4, 2015 at 9:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.