检测RTP流中的VP8关键帧(I帧)

时间:2016-08-05 17:42:20

标签: rtsp rtp vp8

我需要检测RTP数据包中的VP8关键帧。我知道如何删除RTP标头并获取有效负载。

是否有特定的签名/标题?

1 个答案:

答案 0 :(得分:3)

VP8有RFC,它解释了如何检测帧是否为关键帧。见第19.1节。

| Frame Tag                                         | Type  |
| ------------------------------------------------- | ----- |
| frame_tag                                         | f(24) |
| if (key_frame) {                                  |       |
|     start_code                                    | f(24) |
|     horizontal_size_code                          | f(16) |
|     vertical_size_code                            | f(16) |
| }                                                 |       |

The 3-byte frame tag can be parsed as follows:

---- Begin code block --------------------------------------

unsigned char *c = pbi->source;
unsigned int tmp;

tmp = (c[2] << 16) | (c[1] << 8) | c[0];

key_frame = tmp & 0x1;
version = (tmp >> 1) & 0x7;
show_frame = (tmp >> 4) & 0x1;
first_part_size = (tmp >> 5) & 0x7FFFF;

---- End code block ----------------------------------------