Modifying SPS and PPS ids in H.264 bitstream

Viewed 191

What is the best way to modify seq_parameter_set_id and pic_parameter_set_id in an H.264 bitstream?

A bit of background: My encoder (NVENC) is producing some bitstreams with SPS and PPS ids of 1 or 2. When I go to concatenate these bitstreams with others whose SPS and PPS ids are 0, the resulting MP4s cause problems for some decoders (most recently Chrome's Video Decoder Accelerator on Mac). For efficiency I am using ffmpeg's "-codec copy" mechanism to avoid reencoding.

1 Answers

Setup the NVIDIA encoder to start with 0.

In Video_Codec_SDK_11.0.10/include/nvEncodeAPI.h

typedef struct _NV_ENC_CONFIG_H264
{
[snip]
    uint32_t spsId; /**< [in]: Specifies the SPS id of the sequence header */
    uint32_t ppsId; /**< [in]: Specifies the PPS id of the picture header */
[snip]
} NV_ENC_CONFIG_H264;

Or patch SPS, PPS and slice headers

Each SPS contains a seq_parameter_set_id. Parse each SPS set seq_parameter_set_id to '0' and write it back into the stream.

Parse each PPS and set pic_parameter_set_id and seq_parameter_set_id to '0'.

Parse all slice headers and set pic_parameter_set_id to '0'

Related