Commit 26e0ac41 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Fix keyframe detection for VP8 and VP9.

parent c0b755f8
......@@ -266,10 +266,10 @@ func PacketFlags(codec string, buf []byte) (Flags, error) {
if err != nil {
return flags, err
}
flags.Start = vp8.S != 0 && vp8.PID == 0
flags.End = packet.Marker
flags.Keyframe = vp8.S != 0 && (vp8.Payload[0]&0x1) == 0
flags.Keyframe = vp8.S != 0 && vp8.PID == 0 &&
len(vp8.Payload) > 0 && (vp8.Payload[0]&0x1) == 0
flags.Pid = vp8.PictureID
flags.Tid = vp8.TID
flags.TidUpSync = flags.Keyframe || vp8.Y == 1
......@@ -289,7 +289,8 @@ func PacketFlags(codec string, buf []byte) (Flags, error) {
}
flags.Start = vp9.B
flags.End = vp9.E
if (vp9.Payload[0] & 0xc0) == 0x80 {
if vp9.B && len(vp9.Payload) > 0 &&
(vp9.Payload[0] & 0xc0) == 0x80 {
profile := (vp9.Payload[0] >> 4) & 0x3
if profile != 3 {
flags.Keyframe = (vp9.Payload[0] & 0xC) == 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment