Audio and video codec: FLV package format notes

1. Introduction:
FLV is a package format that can be used for both live broadcast and VOD. FLV should be regarded as a product of the 3G era to the early 4G era, because at that time limited by bandwidth capacity and storage limitations, FLV was favored for its good image quality and smaller size. Of course, with the short-lived 5G era With the rise of video and live broadcasting, when storage space is no longer the bottleneck, FLV will eventually be replaced by MP4/TS, etc. FLV packaging has relatively strict audio and video encoding restrictions, that is, the audio format of FLV packaging is mainly AAC/MP3/ SPEEX , the video is mainly H264 . The encapsulation format of FLV is relatively simple, all exist in the form of FLVTAG , and each TAG exists independently .

2. FLVTAG introduction:
1. The FLV file format is divided into two parts: one part is the FLV file header, and the other part is the FLV file content. The FLV file header is analyzed as follows:
insert image description here
It can be seen that when the first three bytes of the code stream file are judged to be FLV, it is considered to be FLV encapsulation.

2. After skipping the encapsulation header, it is the encapsulation content, and the file encapsulation content is arranged as follows:

FLV_HEADER PreTagSize0 TAG1 PreTagSize1 TAG2
flv file header description information size is always 0 (4 bytes) 1st TAG The size of the previous TAG: header+body of the tag (4 bytes) 2nd TAG

3. TAG header layout:
insert image description here
insert image description here
tag_header contains the timestamp of the code stream, and describes whether the subsequent tag_body is an audio stream or a video stream.

4. TAG body layout:
tag_body must have different internal keywords according to the audio and video type. If the TagType is 0x09 read from the FLVTAG Header , then the TAG is video data TAG :
insert image description here
insert image description here
If it is read from the FLVTAG Header When the TagType is resolved to 0x08 , the TAG is audio :
insert image description here
insert image description here
4. FLV analysis tool:
FlvAnalyzer is a very useful tool made by netizens, and the analyzed data is as follows:
insert image description here
5. Acknowledgments:
Most of the content of the blog is excerpted from "FFmpeg" written by Liu Qi and Zhao Wenjie From beginner to proficient" .

Guess you like

Origin blog.csdn.net/achina2011jy/article/details/122171614