织梦CMS - 轻松建站从此开始!

罗索

flv文件格式解读之视频tags

jackyhwei 发布于 2011-04-14 15:11 点击:次 
视频tags数据和swf文件格式中的VideoFrame是相似的.他们的数据是一样的。视频格式的数据的组成如下
TAG:

视频tags的组成:
//---------------------------------------------------------------------------
tag类型 0x09

tag数据大小 3个字节的视频数据大小

tag时间戳 3个字节tag数据应用的时间(毫秒)

tag时间戳扩展 1个字节的时间戳扩展,让时间戳变成4字节,本字节作为时间戳的高位.

streamID 3个字节的类id,总是0

视频tags的数据

//-----------------------------------------------------------------------------------------------------------
视频tags的数据:

视频tags数据和swf文件格式中的VideoFrame是相似的.他们的数据是一样的

视频格式的数据的组成如下:

帧类型 4bit

1: 关键帧keyframe(视频中的关键帧,数据存储的是整个画面完整的数据,可以提取它来生成图片)
2: 中间帧inter frame(关键帧之间的状态,不完整的画面数据,需要依靠前面帧的数据生成)
3: 可任意使用的中间帧disposable inter frame(H.263 only)

视频编码id 4bit

2: Sorenson H.263(mencoder转换所使用的视频编码)
3: Screen video
4: On2 VP6
5: On2 VP6 with alpha channel
6: Screen video version 2

//---------------

视频数据

If CodecID = 2
H263VIDEOPACKET
If CodecID = 3
SCREENVIDEOPACKET
If CodecID = 4
VP6FLVVIDEOPACKET
If CodecID = 5
VP6FLVALPHAVIDEOPAC
KET
If CodecID = 6
SCREENV2VIDEOPACKET

//--------------------------------------------------------------------------------------------

这里说一下Sorenson H.263视频编码以及其数据包:

从swf6开始,flash使用被称作Sorenson H.263的视频编码格式,这种格式基于h.263,一个公开视频编码标准由ITU(国际电信联盟)
提出的.想了解h.263编码格式的朋友可以看http://www.chinavideo.org/index.php?option=com_content&task=view&id=123&Itemid=0


但是Sorenson H.263编码和H.263是有差别的:
下面的特性不存在Sorenson H.263中:
■ GOB (group of blocks) layer
■ Split-screen indicator
■ Document camera indicator
■ Picture freeze release
■ Syntax-based arithmetic coding
■ PB frames
■ Continuous-presence multipoint
■ Overlapped block-motion compensation
下面的特性是Sorenson H.263增加的:
■ Disposable frames (difference frames with no future dependencies)
■ Arbitrary picture width and height up to 65535 pixels
■ Unrestricted motion vector support is always on
■ A deblocking flag is available to suggest the use of a deblocking filter

//---------------------------------------------------------------------------------
H263VIDEOPACKET数据结构:

PictureStartCode UB[17]   和H.263 5.1.1相似
     0000 0000 0000 0000 1

Version   UB[5]   视频格式版本
     Flash Player 6 supports 0 and 1
TemporalReference UB[8]   察看 H.263 5.1.2

PictureSize UB[3]   图像尺寸:
     000: custom, 1 byte
     001: custom, 2 bytes
     010: CIF (352x288)
     011: QCIF (176x144)
     100: SQCIF (128x96)
     101: 320x240
     110: 160x120
     111: 保留

CustomWidth    If PictureSize = 000 UB[8]
     If PictureSize = 001 UB[16]
     否则不存在
     注意:UB[16]不一样UI16,这里不是字节交换的
     单位是像素

CustomHeight    If PictureSize = 000 UB[8]

If PictureSize = 001 UB[16]
     否则不存在
     注意:UB[16]不一样UI16,这里不是字节交换的
     单位是像素

PictureType UB[2]   00: intra frame
     01: inter frame
     10: disposable inter frame
     11: reserved
DeblockingFlag UB[1]   Requests use of deblocking
     filter (advisory only, Flash
     Player may ignore)
Quantizer UB[5]   See H.263 5.1.4
ExtraInformationFlag UB[1] See H.263 5.1.9
ExtraInformation   If ExtraInformationFlag = 1
     UB[8]
     Otherwise absent
     See H.263 5.1.10

     The ExtraInformationFlag-
     ExtraInformation sequence
     repeats until an

ExtraInformationFlag of 0 is
     encountered

Macroblock MACROBLOCK   See following
PictureStuffing varies   See H.263 5.1.13

//------------------------------------------------------------------------------
下面的这些数据是视频图像的具体数据,如果想提取图片的话可以研究一下,但我的目的是从中提取视频的舞台大小.
那么CustomWidth和CustomHeight就够了...


至于其它的数据,常用的就是o2 vp6和带alpha通道的o2 vp6格式了.这里就不多提了,我的目的是从flv中提取meta信息,大多的o2 vp6格式的flv已经有了meta信息了...

文章出自:http://www.5uflash.com/flashjiaocheng/Fmsjiaocheng/2350.html

(roading )
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www.rosoo.net/a/201104/11211.html]
本文出处:5uflash.com 作者:roading
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
将本文分享到微信
织梦二维码生成器
推荐内容