当前位置:网站首页>Flv structure description
Flv structure description
2022-06-09 01:53:00 【knowledgebao】
1. flv
1.1. brief introduction
- One flv file , Every type of tag All belong to one stream ( Or audio , Or video , Or information )
- One flv The file has at most one audio stream , A video stream , There is no case of multiple independent audio and video streams in one file .(mp4 It supports multiple audio and video )
- flv The file format uses the big endian .
1.2. structure
- notes : The following data type in
- UI Represents an unsigned integer , The numbers that follow indicate the number of digits in length . such as UI8, Represents an unsigned integer , The length is one byte .
- UI24 It's three bytes .
- UB Represents a bit field , such as UB5 Represents a byte of 5 position .
1.2.1. The overall structure
- The overall structure is as follows , from Header And Tag form
- Every Tag There is a piece under the 4bytes Space , Used to record this tag The length of ( Not included tagSize The amount of 4 Bytes ), Post can be used for reverse read processing (TagHeader Li Hui records Tag The length of , It can be used for forward reading data processing ).
- body contain Tag0Size+Tag1(Tag1Size)+…+TagN(TagNSize)
- tagSize = 11*8(tagHeaderSize)+tagDataSize(tagHeader Are there in )
| Header |
|---|
| Tag0Size( No, Tag0 So here is 0) |
| Tag1 |
| Tag1Size |
| Tag2 |
| Tag2Size |
| … |
| … |
| TagN(lastTag) |
| TagNSize(lastTagSize) |
1.2.2. Header structure
| Field | type | Comment |
|---|---|---|
| Signature | UI | ’F’(0X46) |
| Signature | UI8 | ‘L’(0X4C) |
| Signature | UI8 | ‘V’(0x56) |
| edition | UI8 | FLV Version of .0x01 Express FLV The version is 1 |
| Keep field | UB5 | The top five must be 0 |
| Is there an audio stream | UB1 | Whether the audio stream has a flag |
| Keep field | UB1 | Must be 0 |
| Is there a video stream | UB1 | Whether there is a flag in the video stream |
| File header size | UI32 | FLV The size of the head (FLV Version is 1 Fixed as 9). The size of the file header here ( Including these four bytes ) |
1.2.3. tag structure
| Field | type | Comment |
|---|---|---|
| TAG type | UI8 | 8: audio,9: video,18: script data( Description information ). |
| data size | UI24 | The size of the data area , barring tag head . The total size of Baotou is 11 Bytes . |
| Time stamp | UI24 | Current frame timestamp , In milliseconds . be relative to FLV The first of the files TAG timestamp . first tag The timestamp of is always 0, the truth is that dts |
| Timestamp extension field | UI8 | If the timestamp is greater than 0xFFFFFF, This byte will be used . This byte is the high of the timestamp 8 position , The upper three bytes are low 24 position . |
| flow ID | U24 | Always 0 |
| Data area | UI8[n] | Distinguish by type , Including video , Audio , Description information |
1.2.4. Audio data structure
| Field | type | Comment |
|---|---|---|
| Audio format | UB4 | 0: Linear PCM, platform endian;1:ADPCM;2:MP3;3:Linear PCM, little endian;4:Nellymoser 16-kHz mono;5:Nellymoser 8-kHz mono;6:Nellymoser;7:G.711 A-law logarithmic PCM;8:G.711 mu-law logarithmic PCM;10:AAC;11:Speex;14:MP3 8-Khz;15:Device-specific sound;9,12,13:reserved; |
| Sampling rate | UB2 | 0:5.5-kHz;1:11-kHz;2:22-kHz;3:44-kHz(For AAC: always 3) |
| Sample size | UB1 | 0:snd8Bit;1:snd16Bit. Only uncompressed formats are valid , The compression format is in accordance with 16bit Sampling processing |
| channel | UB1 | 0: Mono ;1: stereo , Two channel .Nellymoser Must be 0,AAC Must be 1 |
| Voice data | UI8[N] | If it is PCM Linear data , Every time you store 16bit Small end storage , A signed . If the audio format is AAC, The stored data is AAC AUDIO DATA( See the following for the specific format ), Otherwise, it is a linear array . |
AACAUDIODATA
| Field | Type | Comment |
|---|---|---|
| AACPacketType | U8 | 0: AAC sequence header;1: AAC raw |
| Data | UI8[n] | AudioSpecificConfig(ISO 14496-3) or Raw AAC frame data |
1.2.5. Video data structure
| Field | type | Comment |
|---|---|---|
| The frame type | UB4 | 1: keyframe (for AVC, a seekable frame)——h264 Of IDR, Keyframes , Reentrant frame ; 2: inter frame (for AVC, a non- seekable frame),h264 Normal frame ; 3: disposable inter frame (H.263 only);4: generated keyframe (reserved for server use only); 5: video info/command frame( For example, whether the logo is Seek etc. ) |
| code ID | UB4 | 1: JPEG (currently unused); 2: Sorenson H.263;3: Screen video;4: On2 VP6;5: On2 VP6 with alpha channel; 6: Screen video version 2;7: AVC |
| Video data | UI[N] | Different codes , The format is different ,H263VIDEOPACKET/SCREENVIDEOPACKET/VP6FLVVIDEOPACKET/VP6FLVALPHAVIDEOPACKET/SCREENV2VIDEOPACKET/AVCVIDEOPACKET One of the structures of , Refer to the standard for details |
AVCVIDEOPACKET
| Field | type | Comment |
|---|---|---|
| AVC packet type | UI8 | 0:AVC Sequence header 1:AVC NALU unit 2:AVC End of sequence ( Low level avc Unwanted ) |
| CTS | SI24 | If AVC packet The type is 1, Then for cts(Composition time offset) The offset , Otherwise 0, adopt CTS and tag Medium DTS You can get PTS |
| data | UI8[n] | If AVC packet The type is 0, Is the decoder configuration ,sps,pps. If it is 1, It is nalu unit ( It can be more than one ) |
1.3. Relevant concepts
- pts(presentation time stamps),dts(decoder timestamps),cts(CompositionTime)
- pts: Display time , That is, the time when the receiver displays this frame on the display . Unit is 1/90000 second .
- dts: Decoding time , That is to say rtp The timestamp transmitted in the packet , Indicates the decoding order . The unit is 1/90000 second .
- cts The offset :cts = (pts - dts) / 90 .cts In milliseconds .
- flv In file Timestamp and TimestampExtended What you spell is dts. Unit is ms.
- CompositionTime Express PTS be relative to DTS Offset value , Display time (pts) = Decoding time (tag Of the 5~8 byte ) + CompositionTime, The unit is also ms
1.4. Reference material
边栏推荐
- GDB notes (10) - check for memory leak, heap overflow, stack overflow, global memory overflow, and continue using after release
- Shell 硬件信息
- Dom----- register events (bind events)
- 前迪士尼高管称德普将回归《加勒比海盗》 继续演船长
- GCD Locks Dead cycle SpinLock synchronized
- C语言猜数字游戏
- Shell CPU usage
- intel 加速云数智变革
- 【刷穿剑指】剑指 Offer II 003. 前 n 个数字二进制中 1 的个数
- Is it safe for Hualong futures to open an account?
猜你喜欢

Shell循环for while(四)

Intel accélère la transformation intellectuelle du nuage
Go language dolphin scheduler task scheduling processing

ABViewer布局检测器功能以及性能改进

【Unity中的MVC思想——使用MVC制作UI逻辑】

Servlet

GCD Locks Dead cycle SpinLock synchronized

Laravel implements nearby people, shops and houses based on mongodb (LBS)

PHP install CI framework solution

Predicate pushdown of Presto RBO
随机推荐
双检锁为什么需要使用volatile关键字
Go language dolphin scheduler task scheduling processing
[MVC idea in unity -- using MVC to make UI logic]
Redis cluster reports an error cluster_ State:fail, how to solve and restore the cluster (IP problem / incomplete slot allocation problem)
Shell reports server information
Shell loop for while (IV)
Shell循环for while(四)
C language student course management system
浮點數詳解(一篇徹底學通浮點數)
GCD Locks Dead cycle SpinLock synchronized
QT疫情信息管理系统
Assembly language integrated development environment learning notes
Security analysis and demonstration of contract private data leakage
Shell CPU usage
Codeforces Round #797 (Div. 3)A~E
【刷穿剑指】剑指 Offer II 003. 前 n 个数字二进制中 1 的个数
Theoretical basis and underlying technology research materials of audio and video
Diffusion model最近在图像生成领域大红大紫,如何看待它的风头开始超过GAN?
Shell evaluation file / directory status
shell 显示系统信息菜单