FLV file avcdecoderconfigurationrecord and audiospecificconfig Structure

Source: Internet
Author: User
Tags flv file
H264 and aac data streams

The Encapsulation Format of audio and video streams pushed by rtmp is similar to that of FLV. Therefore, we can see that to push h264 and aac live streams to FMS, we need to first send"AVC sequence Header"And"AAC sequence Header", These two pieces of data contain important encoding information. Without them, the decoder cannot be decoded.

AVC sequence header isAvcdecoderconfigurationrecordStructure, which is in the standard document"ISO-14496-15 AVC file format..

The AAC sequence header storesAudiospecificconfigStructure.Audio ISO-14496-3. The description of the audiospecificconfig structure is very complicated. Here I want to simplify it and set the audio format to be encoded in advance. Among them, select "AAC-LC" for Audio Encoding and the audio sampling rate is 44100, therefore, audiospecificconfig is simplified to the following table:

In this way, the content of AVC sequence header and aac sequence header can be basically determined. For more details, you can refer to the relevant documents.

Example

It is not self-painted, so it is omittedSequenceparametersetlength,Pictureparametersetlength

The blue section below is in the FLV file.AvcdecoderconfigurationrecordPart:

00000130 H: 00 00 00 17 00 00 00 01 4D 40 15 ff E1 00 0a; ...... m @.?.
00000140 H: 67 4D 40 15 96 53 01 00 4A 20 01 00 05 68 E9 23; GM @. Large... j... h?
00000150 H: 88 00 00 00 00 2a 08 00 00 52 00 00 00 00 00 00 ;?... *... R ......

 

AccordingAvcdecoderconfigurationrecordStructure Definition:

  • Configurationversion = 01
  • Avcprofileindication = 4D
  • Profile_compatibility = 40
  • Avclevelindication = 15
  • Lengthsizeminusone = FF <-very important. It is the NALU length in H.264 video. The calculation method is 1 + (lengthsizeminusone & 3), and the actual calculation result is 4
  • Numofsequenceparametersets = e1 <-SPS number. The calculation method is numofsequenceparametersets & 0x1f. The actual calculation result is always 1.
  • Sequenceparametersetlength = 00 0a <-SPS Length
  • Sequenceparametersetnalunits = 67 4D 40 15 96 53 01 00 4A 20 <-SPS
  • Numofpictureparametersets = 01 <-PPS, always 1
  • Pictureparametersetlength = 00 05 <-PPS Length
  • Pictureparametersetnalunits = 68 E9 23 88 00 <-PPS

The blue below isAudiospecificconfigPart:

000001e0h: 00 00 00 00 00 af 0011 90 00 00 00 0f 09 00 02 ;.....?.?......

AccordingAudiospecificconfigStructure Definition:

  • Audioobjecttype = (0x11 & 0xf8)> 3 <-obtain the first 5bit and the result is 2
  • Samplingfrequencyindex = (0x11 & 0x7) <1) | (0x90> 7) <-get the last 4 bits, and the result is 3
  • Channelconfiguration = (0x90> 3) & 0x0f <-get the last 4 bits, and the result is 2
  • Framelengthflag = (0x90> 2) & 0x01 <-obtain the last 1 bit and the result is 0.
  • Dependsoncorecoder = (0x90> 1) & 0x01 <-obtain the last 1 bit and the result is 0.
  • Extensionflag = 0x90 & 0x01 <-last 1 bit, always 0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.