当前位置:网站首页>Introduction to FLV documents
Introduction to FLV documents
2022-07-29 01:08:00 【Mr.codeee】
1. brief introduction
FLV yes Adobe A published format that can be used as a live broadcast or an on-demand package , The format is very simple , in FLVTAG There is a form of , And each of these TAG They all exist independently .
2.FLV Introduction to format standards
2.1FLV The file header
| Field | Number of occupancy | explain |
| Signature field | 8 | character "F" (0x46) |
| Signature field | 8 | character "L" (0x4C) |
| Signature field | 8 | character "V" (0x56) |
| edition | 8 | Document version |
| Keep the tag type | 5 | Fixed for 0 |
| Audio tag type | 1 | 1 Show audio labels for |
| Keep the tag type | 1 | Fixed for 0 |
| Video tag type | 1 | 1 Show video tags for |
| Data migration | 32 | Bytes of this header |
Here's what I opened FLV file , see 16 Hexadecimal data .

According to the analysis in the above figure :
- 3 The label of the byte :“F”、“L”、“V”
- 1 Bytes of FLV Document version :0x01
- 5 Bits reserved :00000b
- 1 Bit audio mark bit :1b
- 1 Bits reserved :0b
- 1 Bit video marker bit :1b
- 4 Byte header data offset :0x00 00 00 09
2.2FLV File content format
FLV The contents of the document are as follows :
| Field | Type size | explain |
| the previous TAG Size | 4 byte | Has always been a 0 |
| TAG1 | FLVTAG | first TAG |
| the previous TAG Size | 4 byte | the previous TAG Byte size , Include TAG Of Header+Body,TAG Of Header The size is 11 byte , So for 11 byte +TAG Body Size |
| TAG2 | FLVTAG | the second TAG |
| the previous TAG Size | 4 byte | ......... |
| ......... | 4 byte | ......... |
You can see in the table FLV The format of file content is mainly FLVTAG,FLVTAG In two parts TAGHeader+TAGBody.
As shown in the figure below , I showed an audio TAG, Can see header by 11 byte body by 4 byte , Followed by a 4 Byte size “ the previous TAG Size ”, Values for 15.

The table below for FLVTAG Format analysis of :
| Field | Type size | explain |
| Retain | 2 position | by FMS Retain , by 0 |
| Filter | 1 position | It is mainly used to encrypt the contents of files 0: No preprocessing 1: Preprocessing |
| TAG type | 5 position | 0x08: Audio TAG 0x09: video TAG 0x12: Script data |
| data size | 24 position | TAG Of DATA Size of section |
| Time stamp | 24 position | Display time in milliseconds |
| Extended timestamp | 8 position | Supplementary timestamp added for timestamp |
| flow ID | 24 position | by 0 |
| TAG Of Data | Audio and video media data |
explain :
The size of the timestamp takes 3 Bytes , The biggest expression is 0xFFFFFF(16777215) millisecond , Convert to seconds 16777 second , Approximately equal to 4.66 Hours , If you use FLV The format of , The timestamp used can be stored up to 4.66 Hours .
The extended timestamp size accounts for 1 Bytes , The maximum is 0xFF(255), The extended timestamp makes FLV The original timestamp has been extended , It's not limited to 4.66 Hours , It can also be stored longer , You can probably store 1193 Hours , about 50 God .
2.3VideoTag Data analysis
The data format is shown in the table below :
| Field | Type size | explain |
| The frame type | 4 position | 1: Keyframes 2:P or B frame 3: Applied only to H.263 4: Generate keyframes ( Server usage ) 5: Video information / Command frame |
Code identification | 4 position | 2:Sorenson H.263 3:Screen Video 4:On2 VP6 5: belt Alpha The tunnel On2 VP6 6:Screen Video2 7:H.264 |
| H.264 The package type of | When the code ID is H.264 Time occupation 1 Bytes | 0:H.264 Of Sequence Header 1:NALU 2:H.264 Of Sequence end |
| CTS | When the code ID is H.264 Time occupation 3 Bytes | When encoding using B When the frame ,DTS and PTS It's not equal .CTS Used to represent PTS and DTS Difference between |
| Video data | Video data | Compressed video data |
The detailed explanation is shown in the figure below : Observe the structure on the right tag data()

2.4AudioTag Data analysis
The data format is shown in the table below :
| Field | Type size | explain |
| Sound format | 4 position | I won't list all the details : List a few common 2:MP3 10:AAC 11:Speex |
Audio sampling rate | 2 position | 0:5.5kHz 1:11kHz 2:22kHz 3:44kHz |
| Sample size | 1 position | 0:8 position 1:16 position |
| Audio type | 1 position | 0:Mono sound 1:Stereo sound |
| Audio package type | When the audio is AAC Occupy this byte ,1 Bytes | 0:AAC Sequence Header 1:AAC raw data |
| Audio data | Specific encoded audio data |
The detailed explanation is shown in the figure below : Observe the structure on the right tag data()

2.5ScriptData Data analysis
ScriptData The common way to show is FLV Of MetaData, The data format stored inside is generally AMF data , The table below for ScriptData Storage format .
| Field | Type size | explain |
| type | 8 position | Different values represent AMF Different types of formats 0:Number 1:Boolean 2:String 3:Object 5:Null 6:Undefined 7:Reference 8:ECMA Array 9:Object end marker 10:Strict Array 11:Data 12:Long String |
| data |
3.FLV View tools
边栏推荐
- Charles -- 从0-1教你如何使用抓包工具
- DDD领域驱动设计如何进行工程化落地
- How to create a custom 404 error page in WordPress
- Educational Codeforces Round 132 (Rated for Div. 2)【A~C】
- Summary of preprocessing methods for time series data
- PLATO上线LAAS协议Elephant Swap,用户可借此获得溢价收益
- 【commons-lang3专题】005- ObjectUtils 专题
- Protective copy & stateless
- [notes for question brushing] delete continuous nodes with a total value of zero from the linked list
- UE4 调试常用的打印信息方法
猜你喜欢

Charles -- teach you how to use the packet capturing tool from 0-1

Univariate function integration 1__ Indefinite integral

Connect with Alipay payment

Charles -- 从0-1教你如何使用抓包工具

PLATO上线LAAS协议Elephant Swap,用户可借此获得溢价收益

Cookie和Session

Summary of process and thread knowledge points 2

Have you seen the management area decoupling architecture? Can help customers solve big problems

如何给女友讲明白JS的bind模拟实现

How to deal with the time, scope and cost constraints in the project?
随机推荐
日期转换 EEE MMM dd HH:mm:ss zzz yyyy
Some considerations about ThreadPool
一文让你搞懂MYSQL底层原理。-内部结构、索引、锁、集群
Self made | a 16 bit RISC architecture CPU is self-made by hand
[untitled]
Huawei releases harmonyos 3.0, taking another step towards "Internet of all things"
【commons-lang3专题】004- NumberUtils 专题
Beginner's Guide to electronic bidding
【Jenkins笔记】入门,自由空间;持续集成企业微信;allure报告,持续集成电子邮件通知;构建定时任务
Summary of preprocessing methods for time series data
[target detection] Introduction to yolor theory + practical test visdrone data set
B+ tree~
从零开始实现lmax-Disruptor队列(六)Disruptor 解决伪共享、消费者优雅停止实现原理解析
The digitalization of the consumer industry is upgraded to "rigid demand", and weiit's new retail SaaS empowers enterprises!
Have you seen the management area decoupling architecture? Can help customers solve big problems
“index [hotel/jXLK5MTYTU-jO9WzJNob4w] already exists“
ActiveMQ basic details
Return the member function of *this
面试突击69:TCP 可靠吗?为什么?
双链表的定义 ~