当前位置:网站首页>FLV文件简介
FLV文件简介
2022-07-28 23:54:00 【Mr.codeee】
1.简介
FLV是Adobe发布的一种可以作为直播也可以作为点播的封装格式,格式非常简单,均以FLVTAG的形式存在,并且每一个TAG都是独立存在的。
2.FLV格式标准介绍
2.1FLV文件头
| 字段 | 占用位数 | 说明 |
| 签名字段 | 8 | 字符 "F" (0x46) |
| 签名字段 | 8 | 字符 "L" (0x4C) |
| 签名字段 | 8 | 字符 "V" (0x56) |
| 版本 | 8 | 文件版本 |
| 保留标记类型 | 5 | 固定为0 |
| 音频标记类型 | 1 | 1为显示音频标签 |
| 保留标记类型 | 1 | 固定为0 |
| 视频标记类型 | 1 | 1为显示视频标签 |
| 数据偏移 | 32 | 这个头的字节 |
以下是我打开一个FLV文件,查看16进制数据。

从上图中分析可知:
- 3字节的标签:“F”、“L”、“V”
- 1字节的FLV文件版本:0x01
- 5位保留位:00000b
- 1位音频标记位:1b
- 1位保留位:0b
- 1位视频标记位:1b
- 4字节的文件头数据偏移:0x00 00 00 09
2.2FLV文件内容格式
FLV文件内容如下所示:
| 字段 | 类型大小 | 说明 |
| 上一个TAG的大小 | 4字节 | 一直是0 |
| TAG1 | FLVTAG | 第一个TAG |
| 上一个TAG的大小 | 4字节 | 上一个TAG字节大小,包括TAG的Header+Body,TAG的Header大小为11字节,所以为11字节+TAG Body的大小 |
| TAG2 | FLVTAG | 第二个TAG |
| 上一个TAG的大小 | 4字节 | ......... |
| ......... | 4字节 | ......... |
表中可以看见FLV文件内容格式主要是FLVTAG,FLVTAG分为两部分TAGHeader+TAGBody。
如下图所示,我展示了一个音频的TAG,可以看见header为11字节 body 为4字节,紧接着跟了一个4字节大小的 “上一个TAG的大小”,数值为15。

下表为FLVTAG的格式解析:
| 字段 | 类型大小 | 说明 |
| 保留 | 2位 | 为FMS保留,为0 |
| 滤镜 | 1位 | 主要用来做文件内容加密处理 0:不预处理 1:预处理 |
| TAG类型 | 5位 | 0x08:音频TAG 0x09:视频TAG 0x12:脚本数据 |
| 数据大小 | 24位 | TAG的DATA部分的大小 |
| 时间戳 | 24位 | 以毫秒为单位的展示时间 |
| 扩展时间戳 | 8位 | 针对时间戳增加的补充时间戳 |
| 流ID | 24位 | 为0 |
| TAG的Data | 音视频媒体数据 |
说明:
时间戳的大小占用3个字节,最大表示0xFFFFFF(16777215)毫秒,转换为秒 16777秒,大约等于4.66小时,如果使用FLV的格式,采用的这个时间戳最大可存储至4.66小时。
扩展时间戳大小占1个字节,最大为0xFF(255),扩展时间戳使得FLV原有的时间戳得到了扩展,不仅仅局限于4.66小时,还可以存储得更久,大概可以存储1193个小时,大约50天。
2.3VideoTag数据解析
数据格式如下表所示:
| 字段 | 类型大小 | 说明 |
| 帧类型 | 4位 | 1:关键帧 2:P或B帧 3:仅应用于H.263 4:生成关键帧(服务器使用) 5:视频信息/命令帧 |
编码标识 | 4位 | 2:Sorenson H.263 3:Screen Video 4:On2 VP6 5:带Alpha通道的On2 VP6 6:Screen Video2 7:H.264 |
| H.264的包类型 | 当编码标识为H.264时占用1个字节 | 0:H.264的Sequence Header 1:NALU 2:H.264的Sequence end |
| CTS | 当编码标识为H.264时占用3个字节 | 当编码使用B帧时,DTS和PTS不相等。CTS用于表示PTS和DTS之间的差值 |
| 视频数据 | 视频数据 | 压缩过的视频数据 |
详解如下图所示:观察右边的结构 tag data()

2.4AudioTag数据解析
数据格式如下表所示:
| 字段 | 类型大小 | 说明 |
| 声音格式 | 4位 | 具体我就不全列出来了:列几个常用的 2:MP3 10:AAC 11:Speex |
音频采样率 | 2位 | 0:5.5kHz 1:11kHz 2:22kHz 3:44kHz |
| 采样大小 | 1位 | 0:8位 1:16位 |
| 音频类型 | 1位 | 0:Mono sound 1:Stereo sound |
| 音频包类型 | 当音频为AAC时占用这个字节,1个字节 | 0:AAC Sequence Header 1:AAC raw数据 |
| 音频数据 | 具体编码的音频数据 |
详解如下图所示:观察右边的结构 tag data()

2.5ScriptData数据解析
ScriptData常见的展示方式是FLV的MetaData,里面存储的数据格式一般为AMF数据,下表为ScriptData存储格式。
| 字段 | 类型大小 | 说明 |
| 类型 | 8位 | 不同的值代表着AMF格式不同的类型 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 |
| 数据 |
3.FLV查看工具
FLV解析FLV解析FLV解析FLV解析FLV解析FLV解析FLV解析FLV解析FLV解析FLV解析FLV解析FLV解析-C++文档类资源-CSDN下载
边栏推荐
- 🧐 Table1 | finish your third line watch in one second
- 分类预测 | MATLAB实现TCN时间卷积神经网络的时序分类预测
- Have you seen the management area decoupling architecture? Can help customers solve big problems
- Solid smart contract tutorial (5) -nft auction contract
- 管理区解耦架构见过吗?能帮客户搞定大难题的
- [Commons lang3 topic] 005- objectutils topic
- 快手重点整治搬运、洗稿等方式的养号行为,自媒体平台如何净化内容生态
- 正则表达式
- 数字孪生轨道交通:“智慧化”监控疏通城市运行痛点
- Copy the table in word to wechat as a picture and send it
猜你喜欢

分类预测 | MATLAB实现TCN时间卷积神经网络的时序分类预测

Method of converting inline elements to block elements

线程锁及锁的升降级

How to implement the time impact analysis of the construction project?

Summary of preprocessing methods for time series data

How to carry out engineering implementation of DDD Domain Driven Design
![Cloud function realizes website automatic check-in configuration details [web function /nodejs/cookie]](/img/e3/496247afdb3ea5b9a9cdb8afb0d41b.png)
Cloud function realizes website automatic check-in configuration details [web function /nodejs/cookie]

数字孪生轨道交通:“智慧化”监控疏通城市运行痛点

如何处理项目中的时间、范围和成本限制?

小程序毕设作品之微信校园浴室预约小程序毕业设计成品(5)任务书
随机推荐
Kwai focuses on regulating the number maintenance behavior in the ways of handling and manuscript washing, and how to purify the content ecology on the we media platform
小程序毕设作品之微信校园浴室预约小程序毕业设计成品(5)任务书
[notes for question brushing] specified interval reversal in the linked list
【Web开发】Flask框架基础知识
[notes for question brushing] delete continuous nodes with a total value of zero from the linked list
[raspberry pie] how does the windows computer connect with raspberry pie
Brushless DC motor controller (how much is the hall charge for changing the motor)
[untitled]
iNFTnews | 元宇宙购物体验将成为吸引消费者的一大利器
system verilog常用语法
Plato launched the LAAS protocol elephant swap, which allows users to earn premium income
[Commons lang3 topic] 002 randomutils topic
QT静态编译程序(Mingw编译)
Visual full link log tracking
【刷题笔记】从链表中删去总和值为零的连续节点
Wechat campus bathroom reservation applet graduation design finished product (8) graduation design thesis template
用CDO进行nc数据的不规则裁剪
PLATO上线LAAS协议Elephant Swap,用户可借此获得溢价收益
[Commons lang3 topic] 001 stringutils topic
Charles -- 从0-1教你如何使用抓包工具