当前位置:网站首页>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
边栏推荐
- mysql存储过程 实现创建一张表(复制原表的结构新建的表)
- Consumer unit
- 新一代超安全蜂窝电池,思皓爱跑上市,13.99万起售
- UE4 调试常用的打印信息方法
- [unity] configure unity edit C as vscode
- 小程序毕设作品之微信校园浴室预约小程序毕业设计成品(5)任务书
- 从零开始实现lmax-Disruptor队列(六)Disruptor 解决伪共享、消费者优雅停止实现原理解析
- In the second round, 1000 okaleido tiger were sold out in one hour after logging in to binance NFT again
- Mathematical modeling and detailed explanation of basic knowledge (common knowledge points of Chemistry)
- B-tree~
猜你喜欢
![[untitled]](/img/28/db3b2e1985dc9acf41cdf2004ea0d5.png)
[untitled]

How to deal with the time, scope and cost constraints in the project?

Summary of preprocessing methods for time series data

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

面试突击69:TCP 可靠吗?为什么?

Connect with Alipay payment

ACM SIGIR 2022 | interpretation of selected papers of meituan technical team

solidity实现智能合约教程(5)-NFT拍卖合约
![[Yugong series] go teaching course in July 2022, an array of 020 go containers](/img/06/b2f69599b30c4a93a6240613cbee84.png)
[Yugong series] go teaching course in July 2022, an array of 020 go containers

Cookie和Session
随机推荐
如何执行建设项目的时间影响分析?
Principle and usage setting of large page memory
Brushless DC motor controller (how much is the hall charge for changing the motor)
【commons-lang3专题】005- ObjectUtils 专题
[raspberry pie] how does the windows computer connect with raspberry pie
[notes for question brushing] specified interval reversal in the linked list
Inftnews | yuanuniverse shopping experience will become a powerful tool to attract consumers
【Web开发】Flask框架基础知识
ACM SIGIR 2022 | interpretation of selected papers of meituan technical team
Wechat campus bathroom reservation applet graduation design finished product (5) assignment
Mathematical modeling and detailed explanation of basic knowledge (common knowledge points of Chemistry)
Visual full link log tracking
状态压缩dp-蒙德里安的梦想
Cookie和Session
“index [hotel/jXLK5MTYTU-jO9WzJNob4w] already exists“
Recursion and divide and conquer
What opportunities does the London gold real-time market bring?
Thread lock and its ascending and descending levels
[Commons lang3 topic] 004- numberutils topic
Implement Lmax disruptor queue from scratch (VI) analysis of the principle of disruptor solving pseudo sharing and consumers' elegant stopping