(GO) "Multimedia package format detailed"---AAC adts format analysis

Source: Internet
Author: User

originating from: http://blog.csdn.net/tx3344/article/details/7414543What's a Http://www.it6655.com/2012/08/aac-adts-html1.ADTS?

The Adts full name is (Audio Data Transport Stream) and is a very common transmission format for AAC.

Remember the first time to do Demux, the AAC audio es stream extracted from the FLV package format to the hardware decoder, can not be broadcast, save to the local PC player, I can not broadcast. It collapsed and was later known by looking for information. The general AAC decoder needs to pack the AAC es stream into a Adts format, typically adding a 7-byte Adts header before the AAC es stream. That means you can adts this head as AAC's frameheader.

ADTS AAC
Adts_header AAC ES Adts_header AAC ES ... Adts_header AAC ES

2.ADTS content and Structure

The information sampling rate, channel number and frame length of the ADTS header are relatively useful. Think about it too, if I were a decoder, you give me a bunch of AAC audio es stream I can not solve it. Each AAC stream with Adts header information clearly sends the decoder the information he needs.

In general, Adts header information is 7 bytes, divided into 2 parts:

Adts_fixed_header ();

Adts_variable_header ();


Syncword : The sync head is always 0xFFF, all bits must is 1, which represents the beginning of a Adts frame

ID: MPEG version:0 for MPEG-4, 1 for MPEG-2

Layer: Always: ' 00 '

Profile: Indicates which level of AAC is used, and some chips only support AAC LC. There are 3 types defined in MPEG-2 AAC:

Sampling_frequency_index: Represents the sample rate subscript used to find the value of the sample rate through this subscript in the sampling frequencies[] array.

There is supported frequencies:

    • 0:96000 Hz
    • 1:88200 Hz
    • 2:64000 Hz
    • 3:48000 Hz
    • 4:44100 Hz
    • 5:32000 Hz
    • 6:24000 Hz
    • 7:22050 Hz
    • 8:16000 Hz
    • 9:12000 Hz
    • 10:11025 Hz
    • 11:8000 Hz
    • 12:7350 Hz
    • 13:reserved
    • 14:reserved
    • 15:frequency is written explictly
channel_configuration:Indicates the number of channels

    • 0:defined in AOT specifc Config
    • 1:1 Channel:front-center
    • 2:2 Channels:front-left, Front-right
    • 3:3 Channels:front-center, Front-left, Front-right
    • 4:4 Channels:front-center, Front-left, Front-right, Back-center
    • 5:5 Channels:front-center, Front-left, Front-right, Back-left, Back-right
    • 6:6 Channels:front-center, Front-left, Front-right, Back-left, Back-right, Lfe-channel
    • 7:8 Channels:front-center, Front-left, Front-right, Side-left, Side-right, Back-left, Back-right, LFE-channel
    • 8-15:reserved

frame_length : The length of a Adts frame includes the Adts header and the AAC primitive stream.

adts_buffer_fullness:0x7ff Description is a code stream with variable rate

3. Package AAC into ADTS format

If it is through the embedded high-definition decoder chip to do products, the general situation of decoding work is done by the hardware. So most of the work is to package the AAC original stream into a Adts format and then throw it to the hardware.

By understanding the Adts format, it is easy to package AAC into Adts. We just need to get information about the audio sample rate, channel number, metadata length, AAC format type, etc. in the package format. Then add a Adts header to the front of each AAC original stream to be OK.

By pasting the code that adds the Adts header to the ffmpeg, you can clearly understand the structure of the Adts head:

[HTML]View PlainCopy
  1. int Ff_adts_write_frame_header (Adtscontext *ctx,
  2. uint8_t *buf, int size, int pce_size)
  3. {
  4. Putbitcontext PB;
  5. Init_put_bits (&PB, buf, adts_header_size);
  6. /* Adts_fixed_header */
  7. Put_bits (&PB, 0XFFF); /* Syncword */
  8. Put_bits (&PB, 1, 0); /* ID */
  9. Put_bits (&PB, 2, 0); /* Layer */
  10. Put_bits (&PB, 1, 1); /* Protection_absent */
  11. Put_bits (&PB, 2, ctx->objecttype);/* Profile_objecttype * /
  12. Put_bits (&PB, 4, ctx->sample_rate_index);
  13. Put_bits (&PB, 1, 0); /* Private_bit */
  14. Put_bits (&PB, 3, ctx->channel_conf);/* Channel_configuration * /
  15. Put_bits (&PB, 1, 0); /* Original_copy */
  16. Put_bits (&PB, 1, 0); /* Home */
  17. /* Adts_variable_header */
  18. Put_bits (&PB, 1, 0); /* Copyright_identification_bit */
  19. Put_bits (&PB, 1, 0); /* Copyright_identification_start */
  20. Put_bits (&PB, adts_header_size + SIZE + pce_size); /* Aac_frame_length */
  21. Put_bits (&PB, one, 0x7ff); /* adts_buffer_fullness */
  22. Put_bits (&PB, 2, 0); /* Number_of_raw_data_blocks_in_frame */
  23. Flush_put_bits (&PB);
  24. return 0;
  25. }

(GO) "Multimedia package format detailed"---AAC adts format analysis

Related Article

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.