Question

I am receiving MPEG2-TS stream over RTP. But i am unable to find the end of a particular frame. When only MPEG2 stream came over RTP then marker bit in RTP header is set to 1 when there is end of any frame , but in this case marker bit is always 0. Can anyone help me , how can i find the frame end in case of MPEG2-TS?

Was it helpful?

Solution

According to RFC 2250 M bit should indicate the end of frame in case of mpeg-ts. (3.3 RTP Fixed Header for MPEG ES encapsulation) but many decoder may not be putting it in header.

only other way to find the start of frame is to decode the header of 188 byte mpeg-ts packet.mpeg-ts contains "Payload Unit Start Indicator".

so your algo will be like

  1. RTP data contain integer number of mpeg-ts packets.
  2. each packet starts with 0x47
  3. check the "payload unit start indicator" fiels for each packet
  4. if "payload unit start indicator == 1" check the if PES or PSI
  5. ignore packet if PSI and continue with step-1, else go to next step
  6. for PES packet check "Stream id" if its video you hit a new frame.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top