Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

H264 with multiple PPS and SPS

Tags:

h.264

decoder

I have a card that produces a H264 stream with a SPS (Sequence Parameter Set) and a PPS (Picture Parameter Set), in that order, directly before each I-Frame. I see that most H264 streams contain a PPS and SPS at the first I-Frame.

Is this recommended? Do decoders/muxers typically support multiple PPS and SRS?

like image 951
Paul Knopf Avatar asked Dec 19 '13 12:12

Paul Knopf


People also ask

What is SPS and PPS in h264?

The SPS NAL unit contains parameters that apply to a series of consecutive coded video pictures, referred to as a “coded video sequence” in the H. 264 standard. The PPS NAL unit contains parameters that apply to the decoding of one or more individual pictures inside a coded video sequence.

What is SPS PPS in video?

SPS, PPS. A large number of NAL units are combined to form a single video frame; the metadata of such frame would be transmitted in a Picture Parameter Set (PPS). Likewise, a set of PPS would form an actual video sequence, and the metadata for it would be transmitted in a Sequence Parameter Set (SPS).

What is NALU in h264?

The Network Abstraction Layer (NAL) is a part of the H. 264/AVC and HEVC video coding standards. The main goal of the NAL is the provision of a "network-friendly" video representation addressing "conversational" (video telephony) and "non conversational" (storage, broadcast, or streaming) applications.

What is VPS SPS PPS?

VPS, SPS and PPS contain general video parameters. They provide a robust mechanism for conveying data that are essential to the decoding process. They can be either a part of bitstream or can be stored separately. Slice NAL unit contains data from encoded video frame. It can contain full frame or its part.


2 Answers

H.264 comes in a variety of stream formats. One variation is called "Annex B".

(AUD)(SPS)(PPS)(I-Slice)(PPS)(P-Slice)(PPS)(P-Slice) ... (AUD)(SPS)(PPS)(I-Slice).

Typically you see SPS/PPS before each I frame and PPS before other slices.

Most decoders/muxers are happy with "Annex B" and the repetition of SPS/PPS.

Most decoders/muxers won't do anything meaningful if you change the format and SPS/PPS midstream.

Most decoders/muxers parse the first SPS/PPS as part of a setup process and ignore subsequent SPSs.

Some decoders/muxers prefer H.264 without the (AUD), start codes and SPS/PPS. Then you have to feed SPS/PPS out of band as part of setting up the decoders/muxers.

like image 84
Markus Schumann Avatar answered Sep 20 '22 12:09

Markus Schumann


An IDR frame, or an I-slice can not be decoded without a SPS and PPS. In the case of a container like mp4, the SPS and PPS is stored away from the video data in the file header. Upon playback the mp4 is parsed, the SPS/PPS is used to configure the AVC decoder once, then video can be played back starting at any IDR/I-slice.

There is a second scenario, Live video. With live video, there is no file header, because there is no file. So when a TV tunes into a channel, where does it get the SPS/PPS? Because television is broadcast, meaning the television has no way to request the SPS/PPS, it is repeated in the stream.

So when you start encoding video, your encoder does not know what you intend to do with the video. Now if the extra SPS/PPS show up in an mp4, the decoder just ignores them, but if you are streaming to a TV, without them the stream would never play. So most of the default to repeating SPS/PPS just in case.

like image 23
szatmary Avatar answered Sep 19 '22 12:09

szatmary