Adobe Flash Video File Format Specification Version 10.1
File Tag包括Tag Header和Tag Data两部分。不同类型的Tag的Header结构是相同的,但是Data结构各不相同
File Tag Header数据。
当前版本的Tag Header结构占用11个字节,如上图绿色部分所示:
第1个字节表示Tag类型,包括音频(0x08)、视频(0x09)和script data(0x12),其他类型值被保留。 即为0x09
第2-4字节为UI24类型的值,表示该Tag Data部分的大小。 即为0x1E=30
第5-7字节为UI24类型的值,表示该Tag的时间戳(单位为ms),第一个Tag的时间戳总是0。即为0x53=83,此时间戳表示解码时间!!!
第8个字节为时间戳的扩展字节,当24位数值不够时,该字节作为最高位将时间戳扩展为32位值。 即为0x00
第9-11字节为UI24类型的值,表示stream id,总是0. 即为0x00
Video Tag Header数据:
- 第一个字节中的前4个bit表示frame type:
Type of video frame. The following values are defined:
1 = key frame (for AVC, a seekable frame)
2 = inter frame (for AVC, a non-seekable frame)
3 = disposable inter frame (H.263 only)
4 = generated key frame (reserved for server use only)
5 = video info/command frame
上图中值为2,表示inter frame
- 第一个字节中的后4个bit表示CodeID
Codec Identifier. The following values are defined:
2 = Sorenson H.263
3 = Screen video
4 = On2 VP6
5 = On2 VP6 with alpha channel
6 = Screen video version 2
7 = AVC
上图中值为7,表示AVC编码格式
- 第二个字节表示AVCPacketType,如果是AVC编码时,则存在此字节,并有如下定义:
The following values are defined:
0 = AVC sequence header
1 = AVC NALU
2 = AVC end of sequence (lower level NALU sequence ender is
not required or supported)
上图中值为1,表示AVC NALU。
IF AVCPacketType == 1, One or more NALUs (Full frames are required)
- 第三到五字节表示CompositionTime, 如果是AVC编码并且AVCPacketType等于1时,则存在此值
IF AVCPacketType == 1
Composition time offset
ELSE
0
See ISO 14496-12, 8.15.3 for an explanation of composition
times. The offset in an FLV file is always in milliseconds.
上图中值为0xA7=167,则PTS = CTS + DTS, 及PTS = 0xA7 + 0x53 = 0xFA
Video Tag Body