Перейти к содержимому

Sps pps что это

  • автор:

Sps pps что это

H.264 code stream first NALU isSPS(Sequence Parameter Set SEQUENCE PARAMETER SETCorresponding to the syntax of the H264 Standard Document 7.3.2.1 Sequence Parameter Set.

H.264 code stream second NALU is PPS(Image parameter set Picture Parameter SetCorresponding to the syntax of the H264 Standard Document 7.3.2.2 Sequence Parameter Set.

H.264 code stream third NALU isIDR(Instant decoder refresh)Corresponding to the syntax of the H264 Standard Document 7.3.3 Sequence Parameter Set.

The SPS and PPS strings of the H.264 in the SDP include the information parameters required to initialize the H.264 decoder, including the PROFILE, LEVEL, the width and high, and the DEBLOCK filter, and the like used in the encoding.

2, the difference between I frame and IDR frame in H2.64

I with IDR The frame is to use intra prediction. They are all in the same thing, in the coding and decoding for convenience, to distinguish the first I frame and other I frames, so the first first I frame is called IDR, so it is convenient to control the encoding and decoding flow. The role of the IDR frame is to refresh immediately, making the error induced, starting from the IDR frame, re-calculate a new sequence to start encoding. The I frame does not have a random access, this function is borne by the IDR, and the IDR will cause the DPB (the reference frame list — this is the key) clear, and I will not. IDR Image must be I Image, but I Image is not necessarily IDR image. A sequence can have a lot of I images, and the image after the I image can reference the image between the I image to exercise reference.

For IDR frames, all frames before the IDR frame cannot reference the contents of the frame before the IDR frame, which is reversed, for ordinary I-frames, B- and P-frames after it can be referenced. I-frames before normal I-frames. From a random access, the player can always play from one IDR frame because there is no frame reference before it. However, you cannot start playing from any point in a video without an IDR frame, because the following frames are always referenced by the previous frames.

3, SPS and PPS separation and addition

When the H.264 code stream is separated, the files that directly store the AVPACKET may not be played.

If the viewing format is the TS (MPEG2 Transport Stream), the files directly stored can be played. The multiplex format is FLV, and MP4 is not. After long-term data search, FLV, MP4 belongs to "special containers", and it is necessary to obtain the playable H.264 code stream with the following processing:

Separate some package format (for example MP4/FLV/MKV Alien H.264 When you need to write first SPS with PPS Otherwise, it will result in separating data SPS 、 PPS Can’t play. The SPS and PPS information of the H.264 code stream are stored in the EXTRADATA of the AVCODECCONTEXT structure. The BitStream Filter processing name "H264_MP4ToanNexb" is required in FFMPEG. There are two ways:

(1) Use BitStream Filter to handle each Avpacket (simple)

  • Enter parameters: Bit Flow Filter Name
  • Output parameters: A context of a bit stream filter is initialized according to the creation of a bitstream filter and initializes a bitstream filter

(2) Handmade SPS, PPS (slightly complicated)

After the EXTRADATA data of AvcodecContext is processed after the BitStream Filter process, you get SPS, PPS, and copy to each IDR frame. By looking at FFMPEG Source Codes We found that there is no separator (0x00000001) in the starting data in Avpacket, nor bytes of 0x65, 0x67, 0x68, 0x41, so you can affirm this is not a standard NALU. In fact, 4 characters in Avpacket represent the length of NALU, starting from the 5th byte is NALU data. So directly replace the first 4 bytes of Avpacket to 0x00000001 to get standard NALU data.

Introduction to SPS&PPS and AudioSpecificConfig (End)

The most simple iOS push stream code, video capture, soft coding (FAAC, X264), hard coding (AAC, H264), beauty, FLV coding, RTMP protocol, updated code parsing, you want to learn the knowledge here, willing to understand live technology students come to see!!

# description SPS/PPS/AudioSpecificConfig spspps/AudioSpecificConfig paper has mentioned many times before.

Spspps is a concept in H264, which contains some coding information, such as profile, image size and so on. In FLV, contains spspps part called AVC Sequence header (namely AVCDecoderConfigurationRecord, refer to the ISO — 14496-15 AVC file format).

AudioSpecificConfig is a concept in AAC that contains audio information such as sampling rate, number of channels, etc. The part of the FLV that contains AudioSpecificConfig is called the AAC Sequence header (AudioSpecificConfig, see ISO-14496-3 Audio).

Both data formats can be referred to in standard documentation or blog posts on the web, but here’s how to capture and process the data in hard/soft coding.

As you can see, these two concepts are actually encoded as a configuration file, holding some common attributes of the subsequent audio and video data.

spspps

After h264 coding, spSPPS data can be obtained directly.

The code for obtaining SPSPPS data by soft coding is in aw_x264.c

Hard-coded SPSPPS data can be retrieved via keyframes. The code is in AWHWH264Encoder. M

After obtaining SPSPPS data successfully, you can use aw_encoder_create_sps_pps_tag in aw_SW_X264_encoder. C to create a corresponding video tag, and then send it as a common video tag.

After the AAC soft coding library FAAC is initialized, AudioSpecificConfig data can be obtained directly in aw_faac.c.

In addition, AudioSpecificConfig data structures are very simple and you can easily construct one yourself. Refer to AWHWAACEncoder createAudioSpecificConfigFlvTag function of m.

After you have AudioSpecificConfig data, you can use aw_encoder_create_audio_specific_config_TAG in aw_sw_FAac_encoder. C to create the corresponding FLV audio tag. It can then be sent as a normal Audio tag.

After the RTMP connection is successful, you must send the tags corresponding to spSPPS and AudioSpecificConfig first; otherwise, videos cannot be played.

Что заставляет кодировщик часто генерировать SPS\PPS?

Хочу записывать mp4 из webrtc стрима. Проблема в том, что кодировщик chrome почему то слишком часто (с каждым IDR) посылает ещё и SPS\PPS пакеты. Парсил и сравнивал эти SPS\PPS, они все одинаковые (за исключением битов выравнивания в конце rbsp_alignment_zero_bit). Разрешение в потоке идет постоянное, не изменяется

Смотрел другие видео, везде SPS посылается один, в начале видео. В моем же случае они сыпятся с каждым IDR

Вот примерный порядок NAL (вырезал nal_unit_type=1, т.к. их слишком много)

Последовательность такая SPS PPS IDR, SPS PPS IDR, SPS PPS IDR. Ничего не понимаю, зачем слать каждый раз SPS, если он не меняется. Что ещё может меняться в стриме, что заставляет кодировщик слать эти SPS?

SPS/PPS/VPS/VUI

VPS, SPS, and PPS contain general video parameters. They provide a robust mechanism for conveying data that is essential to the decoding process. They can be either a part of a bitstream or can be stored separately.

Sequence parameter set (SPS) — a syntax structure containing syntax elements that apply to zero or more entire coded layer video sequences. SPS contains syntax elements such as the picture’s width, height, and bit depth.

Picture parameter set (PPS) — a syntax structure containing syntax elements that apply to zero or more entire coded pictures. PPS contains information on entropy coding mode, slice groups, motion prediction, quantization parameters (QP), and deblocking filter.

Video parameter set (VPS) includes syntax elements for session negotiation such as profile and level.

SPS has an optional part that includes the video usability information (VUI) — parameters, which provide additional information about higher-level properties of video content such as aspect ratio, color space, chroma location, bitstream restrictions, timing, etc.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *