type
status
date
slug
summary
tags
category
icon
password
Property
Mar 20, 2023 03:15 AM
基础知识
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F2e879c8d-99f9-49f1-b0d3-c7b56671859a%2FUntitled.png?table=block&id=ee673752-0a03-451f-8273-b4e07b46d904)
ADIF 和 ADTS
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fd8240e0f-4821-46b6-8491-53e4cf577a9f%2FUntitled.png?table=block&id=d60a5b9a-e8e1-49d1-8b5e-001738a71875)
AAC 结构体
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F1cf2103f-a3c2-44fb-aca7-b9937b28772a%2FUntitled.png?table=block&id=92447582-ef26-4935-9774-26c34bbfc867)
adts_fixed_header 组成
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F33f32df3-3b41-4f8a-b1b2-9e0b73e77a37%2FUntitled.png?table=block&id=7d56c5c4-e2df-481a-bee6-2bfe98f0db51)
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F889aa410-0528-4975-94c1-d73805b5582e%2FUntitled.png?table=block&id=0c09ead2-205f-4b56-bb2c-275883a72c33)
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F6a4d3b88-11b2-4ab4-8c1c-bf3d158ad297%2FUntitled.png?table=block&id=de41ad1a-2bd1-4558-a74c-c1b74fea4064)
- profile:
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F43740213-5ecf-40e5-a099-43057aeb3462%2FUntitled.png?table=block&id=a8e9fb34-8c14-4198-a08d-10bee0353690)
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Ffbd4c9d4-d877-4d85-9d25-65b70ed641ca%2FUntitled.png?table=block&id=498f90ff-0d81-455b-b727-2955df8793e9)
FFmpeg 中对应的定义:
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F23ccd072-2616-471b-a9a5-2851a8920d82%2FUntitled.png?table=block&id=37ba70b6-9b66-4b92-8f93-89b3f37be222)
- sampling_frequency_index:
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fa6252ae6-ed21-4661-a5b1-ba857d6aaf00%2FUntitled.png?table=block&id=6400b6c1-3985-4874-8137-0ad1f697199f)
- channel_configuration:
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F9452f29d-9e5f-4fb3-acbc-1990f94b728f%2FUntitled.png?table=block&id=c4e9286f-a261-44ad-abd2-36d63812ac6f)
adts_variable_header 组成
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F94275255-7afa-4c04-a9b9-5cc7e726a729%2FUntitled.png?table=block&id=faf9111b-9147-46f2-98bc-e6116d607f45)
ADTS 的 AAC 分析
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F03bf0703-bea7-4411-8008-9750ec740c0b%2FUntitled.png?table=block&id=f9e4e759-a637-46a4-b440-f16654b599dd)
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F5aa460ca-4f20-4cfc-96fa-f082129b1c2b%2FUntitled.png?table=block&id=803fa536-33b1-43a1-aa45-6a3ac1fc2410)
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F58ba12f9-4950-411e-820e-4ba9ea492360%2FUntitled.png?table=block&id=6608c588-ec37-4891-8809-3dd26c09d016)
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F46e23394-af47-43e2-b6ea-2339f525996b%2FUntitled.png?table=block&id=c475ff74-36d0-49c7-abe6-f3046f3de725)
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fe0efc264-b812-4ec6-af35-03ecb331c1e1%2FUntitled.png?table=block&id=88dd78d6-be97-4ce5-8a4f-0a283d7f951a)
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Facaf3cf2-90df-4e2a-98a2-40605ff7e4fd%2FUntitled.png?table=block&id=63786813-4890-4de9-afda-941fc82f2888)
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F60524952-18d8-4f37-b667-220c647693f6%2FUntitled.png?table=block&id=d86c23b0-1399-47e9-a197-3a8f7f69905a)
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F405171fb-9bb5-4275-88f6-e8f43d3e6409%2FUntitled.png?table=block&id=4e0fe276-74ed-44c6-a583-06028f924e76)
提取 AAC 代码
- 从视频文件中提取音频数据并封装为 AAC
- adts_header 函数分析:
- 具体的代码逻辑如下:
- 第1个字节高8位为0xff,低4位为0xf0,这是ADTS头的同步字,用于标识数据帧的开始。
- 第2个字节的第3位为MPEG版本,第4和5位为Layer,这些信息描述了AAC编码的版本和层次。
- 第2个字节的第1位为保护标志,表示是否进行了错误保护,这里是1,表示没有进行保护。
- 第2个字节的第2位为私有标志,这里是0,表示不使用私有标志。
- 第2个字节的第6、7位为音频格式,这里是profile,表示使用哪种AAC配置。
- 第2个字节的第8-11位为采样率,这里是sampling_frequency_index,表示使用哪种采样率。
- 第3个字节的第1-4位为声道数,这里是channels。
- 第3个字节的第6-9位为采样率,这里也是sampling_frequency_index。
- 第3个字节的第5位为原始标志,表示音频是否为原始音频,这里是0,表示不是原始音频。
- 第3个字节的第4位为版权标志,表示是否使用了版权保护,这里是0,表示没有使用。
- 第3个字节的第3位为版权标志开始标志,表示版权信息开始的位置,这里是0,表示没有版权信息。
- 第3个字节的第8-9位和第4个字节的前2位为数据帧长度,这里是adtsLen。
- 第4个字节的第3-9位为数据帧长度,这里也是adtsLen。
- 第5个字节的第1-3位为数据帧长度,这里也是adtsLen。
- 第5个字节的第4-8位为缓冲区满标志,这里是0x7ff,表示缓冲区已满。
- 第6个字节的第1-6位为缓冲区满标志,这里也是0x7ff。
- 第7个字节的第1-2位为数据块数,这里是0,表示只有1个数据块。
这段代码是生成AAC数据的ADTS头的代码,ADTS头是一种将AAC音频编码后的数据进行封装的格式,其中包含了音频格式、长度、采样率、声道数等信息。这些信息可以帮助解码器正确的解析音频数据。
- 作者:OctalZero
- 链接:https://octalzero.com/article/ae661974-5f1a-4352-9ae6-38022679a90d
- 声明:本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。
相关文章