FLV 数据封装格式
https://www.cnblogs.com/chyingp/p/flv-getting-started.html
https://blog.csdn.net/ai2000ai/article/details/77530741
从整个文件上开看,FLV是由 header 和 Body 组成.
1、Header
Signature: FLV 文件的前3个字节为固定的‘F’‘L’‘V’,用来标识这个文件是flv格式的.在做格式探测的时候,
如果发现前3个字节为“FLV”,就认为它是flv文件.
Version: 第4个字节表示flv版本号.
Flags: 第5个字节中的第0位和第2位,分别表示 video 与 audio 存在的情况.(1表示存在,0表示不存在)
DataOffset : 最后4个字节表示FLV header 长度.
2 FLV body = TagSize|Tag | TagSize | Tag... ...
FLV header之后,就是 FLV File Body.
FLV File Body是由一连串的back-pointers + tags构成.back-pointers就是4个字节数据,表示前一个tag的size.
3.FLV Tag
FLV文件中的数据都是由一个个TAG组成,TAG里面的数据可能是video、audio、scripts.
onMetaData 包含在scripts 中, 含有十分重要的信息, 比如宽高、duration、filesize 等
下表是TAG的结构:
1.FLVTAG
Field | Type | Comment |
Reserved | UB [2] | Reserved for FMS, should be 0 |
Filter | UB [1] | Indicates if packets are filtered. 0 = No pre-processing required. 1 = Pre-processing (such as decryption) of the packet is required before it can be rendered. Shall be 0 in unencrypted files, and 1 for encrypted tags. See Annex F. FLV Encryption for the use of filters. |
TagType | UB [5] |
Type of contents in this tag. The following types are |
DataSize | UI24 | Length of the message. Number of bytes after StreamID to end of tag (Equal to length of the tag – 11) |
Timestamp | UI24 | Time in milliseconds at which the data in this tag applies. This value is relative to the first tag in the FLV file, which always has a timestamp of 0. |
TimestampExtended | UI8 | Extension of the Timestamp field to form a SI32 value. This field represents the upper 8 bits, while the previous Timestamp field represents the lower 24 bits of the time in milliseconds. |
StreamID | UI24 | Always 0. |
AudioTagHeader | IF TagType == 8 AudioTagHeader |
|
VideoTagHeader | IF TagType == 9 VideoTagHeader |
|
EncryptionHeader | IF Filter == 1 EncryptionTagHeader |
|
FilterParams | IF Filter == 1 FilterParams |
|
Data | IF TagType == 8 AUDIODATA IF TagType == 9 VIDEODATA IF TagType == 18 SCRIPTDATA |
Data specific for each media type. |
TagType: TAG中第1个字节中的前5位表示这个TAG中包含数据的类型,8 = audio,9 = video,18 = script data.
DataSize:StreamID之后的数据长度.
Timestamp和TimestampExtended组成了这个TAG包数据的PTS信息,记得刚开始做FVL demux的时候,并没有考虑TimestampExtended的值,直接就把Timestamp默认为是PTS,后来发生的现 象就是画面有跳帧的现象,后来才仔细看了一下文档发现真正数据的PTS是PTS= Timestamp | TimestampExtended<<24.
StreamID之后的数据就是每种格式的情况不一样了,接下格式进行详细的介绍.
Audio Tags
如果TAG包中的TagType==8时,就表示这个TAG是audio。
StreamID之后的数据就表示是AudioTagHeader,AudioTagHeader结构如下:
最新文章
- 发布一个自用的ansi转utf8程序
- Class.forName的使用
- Js中Prototype、__proto__、Constructor、Object、Function关系介绍
- javascript guid(uuid)
- Oracle 获取用户表的字段定义
- 通过调用门进行有特权级变换的转移,详细注解 对pmtest5.asm解释很详细.
- ipconfig命令
- jQuery 序列化表单 serialize() serializeArray()
- css渐变色
- (转)Tomcat 7 访问 Manager 和 Host Manager
- REST架构概述
- iOS悬浮窗口(无论界面跳转、View始终在视图上显示,可移动)
- 解决linux用户切换失败 su:execute /usr/bin 没有权限
- Liferay7 BPM门户开发之9: 流程表单数据动态映射体系
- 在VMware中安装Mac OS
- 2019.01.20 bzoj3784: 树上的路径(二分答案+点分治)
- VS2013启动浏览器链接(BrowserLink),导致页面脚本错误和页面加载变慢
- 【BZOJ】1013 [JSOI2008]球形空间产生器sphere(高斯消元)
- 05 Go 1.5 Release Notes
- erlang的一些小技巧(不定期更新)