Flv视频格式解析
Flv文件分为2部分,头和数据部分。
Flv视频头
标准的视频头如下:
Field | Data Type | Default | Details |
---|---|---|---|
Signature | byte[3] | “FLV” | Always “FLV” |
Version | uint8 | 1 | Only 0x01 is valid |
Flags | uint8 bitmask | 0x05 | Bitmask: 0x04 is audio, 0x01 is video (so 0x05 is audio+video) |
Header Size | uint32_be | 9 | Used to skip a newer expanded header |
数据
视频头结束后,是数据部分,这部分是由一个一个的FLV tags组成,这个tag中包含一个15字节的头,其后紧跟实际的数据。头的前4个自己用来说明前面的 FLV tags的大小,主要用来回放(向前拖动)
Field | Data Type | Default | Details |
---|---|---|---|
Size of previous packet | uint32_be | 0 | For first packet set to NULL |
Packet Type | uint8 | 18 | For first packet set to AMF Metadata |
Payload Size | uint24_be | varies | Size of packet data only |
Timestamp Lower | uint24_be | 0 | For first packet set to NULL |
Timestamp Upper | uint8 | 0 | Extension to create a uint32_be value |
Stream ID | uint24_be | 0 | For first stream of same type set to NULL |
Payload Data | freeform | varies | Data as defined by packet type |
支持的视频编码:
Id | Video encoding |
---|---|
0 | RGB |
1 | run-length |
2 | Sorenson's H.263 |
3 | Screen 1 |
4 | On2 TrueMotion VP6 |
5 | VP6 with alpha |
6 | Screen 2 |
7 | MP4 H.264 |
8 | ITU H.263 |
9 | MPEG-4 ASP. |
支持的音频编码:
Id | Audio encoding |
---|---|
0 | native PCM |
1 | ADPCM |
2 | MPEG layer 3 |
3 | PCM – little endian |
4 | Asao 16 kHz |
5 | Asao 8 kHz |
6 | Asao parameter rate |
7 | a-law |
8 | μ-law |
Id | Audio encoding |
---|---|
10 | MP4 AAC |
11 | Speex |
版权所有,禁止转载. 如需转载,请先征得博主的同意,并且表明文章转载自:IT夜班车,否则按侵权处理.