55
66FLV封装格式是由一个文件头(FLV header)和很多tag组成(FLV body)组成的二进制文件。Tag中包含了音频数据以及视频数据。FLV的结构如下图所示。
77
8- ![ img] ( https://img-blog.csdn.net/20160118103525777 )
8+ ![ Image] ( https://raw.githubusercontent.com/CharonChui/Pictures/master/flv_tag.jpg?raw=true )
9+
10+
911
1012tag又可以分成三类: audio ,video,script,分别代表音频流,视频流,脚本流,而每个tag又由tag header和tag data组成。
1113
1214
1315
1416#### FLV整体结构图:
1517
16- ![ img] ( https:////upload-images.jianshu.io/upload_images/9078032-4d1e3f09df181782.png?imageMogr2/auto-orient/strip|imageView2/2/w/843 )
18+ ![ Image] ( https://raw.githubusercontent.com/CharonChui/Pictures/master/flv_tag.jpg?raw=true )
19+
20+
21+
22+ ![ Image] ( https://raw.githubusercontent.com/CharonChui/Pictures/master/flv_header_tag.png?raw=true )
1723
1824
1925
2026#### FLV文件头结构图
2127
22-
2328
24- ![ img] ( https:////upload-images.jianshu.io/upload_images/9078032-b0bab07d69f55262.png?imageMogr2/auto-orient/strip|imageView2/2/w/624 )
29+
30+ ![ Image] ( https://raw.githubusercontent.com/CharonChui/Pictures/master/flv_tag_2.png?raw=true )
2531
2632
2733
@@ -33,7 +39,7 @@ tag又可以分成三类:audio,video,script,分别代表音频流,视频流
3339
3440 tag结构图:
3541
36- ![ img ] ( https:////upload-images.jianshu.io/upload_images/9078032-24c834de3b517f60 .png?imageMogr2/auto-orient/strip|imageView2/2/w/853 )
42+ ![ Image ] ( https://raw.githubusercontent.com/CharonChui/Pictures/master/flv_body_tag .png?raw=true )
3743
3844 tag header:
3945
@@ -51,25 +57,29 @@ tag又可以分成三类:audio,video,script,分别代表音频流,视频流
5157
5258 音频TagData结构分析:
5359
54- ![ img ] ( https:////upload-images.jianshu.io/upload_images/9078032-2339809cce2f8ab0 .png?imageMogr2/auto-orient/strip|imageView2/2/w/852 )
60+ ![ Image ] ( https://raw.githubusercontent.com/CharonChui/Pictures/master/flv_audio_tag .png?raw=true )
5561
5662 音频参数中各字段的值及其意义如下表所示:
5763
58- ![ img] ( https:////upload-images.jianshu.io/upload_images/9078032-7265d2aa76864647.png?imageMogr2/auto-orient/strip|imageView2/2/w/654 )
64+
65+
66+ ![ Image] ( https://raw.githubusercontent.com/CharonChui/Pictures/master/flv_audio_tag2.png?raw=true )
5967
6068 音频参数对照表
6169
6270 视频TagData结构:
6371
64- ![ img ] ( https:////upload-images.jianshu.io/upload_images/9078032-78db278c8115b2a8 .png?imageMogr2/auto-orient/strip|imageView2/2/w/851 )
72+ ![ Image ] ( https://raw.githubusercontent.com/CharonChui/Pictures/master/flv_video_tag .png?raw=true )
6573
6674
6775
6876 Script TagData结构
6977
7078 Script Tag通常被称为Metadata Tag,会放一些关于FLV视频和音频的元数据信息如:duration、width、height等。通常此类型Tag会跟在File Header后面作为第一个Tag出现,而且只有一个。
7179
72- ![ img] ( https:////upload-images.jianshu.io/upload_images/9078032-52b10dcecd85efe9.png?imageMogr2/auto-orient/strip|imageView2/2/w/843 )
80+ ![ Image] ( https://raw.githubusercontent.com/CharonChui/Pictures/master/flv_script_tag.png?raw=true )
81+
82+
7383
7484
7585
@@ -81,13 +91,15 @@ tag又可以分成三类:audio,video,script,分别代表音频流,视频流
8191
8292 第二个AMF包结构图:
8393
84- ![ img ] ( https:////upload-images.jianshu.io/upload_images/9078032-023c79ab3f1c9f83 .png?imageMogr2/auto-orient/strip|imageView2/2/w/842 )
94+ ![ Image ] ( https://raw.githubusercontent.com/CharonChui/Pictures/master/flv_awf_tag .png?raw=true )
8595
8696 第二个AMF包结构图
8797
8898 第1个字节表示AMF包类型,一般总是0x08,表示数组。第2-5个字节为UI32类型值,表示数组元素的个数,后面即为各数组元素的封装。数组元素为元素名称和值组成的对。“数组元素结构”部分是推测,已经确认适用于duration、width、height等常见元素,但并不确认适用于所有元素。常见的数组元素如下表所示。
8999
90- ![ img] ( https:////upload-images.jianshu.io/upload_images/9078032-ca0f9296f78d19e6?imageMogr2/auto-orient/strip|imageView2/2/w/407 )
100+ ![ Image] ( https://raw.githubusercontent.com/CharonChui/Pictures/master/flv_amf_tag.jpg?raw=true )
101+
102+
91103
92104
93105
0 commit comments