h.264http-live-streamingmpeg2-tspacket-injection

How are access units aligned within PES packets in Apple's HLS?


Does Apple specify this? How many access units should one put in a PES packet payload?

Also, I'm wondering which prefix start codes (if any) are present in PES packets. I assume that the one preceding the first NAL unit within an access unit is useless and mustn't be put. Right?

I'd like to know how it's done specifically in HLS - not necessarily any other MPEG-2 TS application.


Solution

  • I'd like to know how it's done specifically in HLS - not necessarily any other MPEG-2 TS application.

    HLS is a standard MPEG-2 TS stream. HLS does not do it any differently, except limit to a single audio and singe video stream. And limit codecs to AVC/AAC/MP3

    For the rest of the answers, I will assume you are referring to the AVC codec. (AAC and and MP3 have different answers)

    How many access units should one put in a PES packet payload?

    One. However for efficiency, the last NALU may be truncated on a TS boundary, and the remainder prepended to the next AU at the start of the next PES. This is optional, but it does reduce bitrate.

    I'm wondering which prefix start codes (if any) are present in PES packets.

    MPEGTS requires annex B style start codes. One start code before every NALU. An AU will have several NALUs as AUDs are required in mpegts.

    I assume that the one preceding the first NAL unit within an access unit is useless and mustn't be put. Right?

    Completely wrong. Every NALU must begin with a start code,