gpt4 book ai didi

parsing - h264 引用帧

转载 作者:行者123 更新时间:2023-12-04 17:50:07 25 4
gpt4 key购买 nike

我正在寻找一种在 h264 流中查找引用帧的算法。我在不同的解决方案中看到的最常见的方法是查找访问单元分隔符和 IDR 类型的 NAL。不幸的是,我检查的大多数流都没有 IDR 类型的 NAL。我将不胜感激。问候 jack

最佳答案

H264 帧由一个特殊的标签分割,称为起始码前缀,它可以是 0x00 0x00 0x010x00 0x00 0x00 0x01。两个起始码之间的所有数据都包含在 H264 语音中的一个 NAL 单元。所以你要做的是在你的 h264 流中搜索 startcode 前缀。紧跟在 startcode 前缀后面的字节是 NAL header 。 NAL header 的最低 5 位将为您提供 NAL 单元类型。如果 nal_unit_type = 5,则该特定 NAL 单元是引用帧。

类似这样的:

void h264_find_IDR_frame(char *buf)
{
while(1)
{
if (buf[0]==0x00 && buf[1]==0x00 && buf[2]==0x01)
{
// Found a NAL unit with 3-byte startcode
if(buf[3] & 0x1F == 0x5)
{
// Found a reference frame, do something with it
}
break;
}
else if (buf[0]==0x00 && buf[1]==0x00 && buf[2]==0x00 && buf[3]==0x01)
{
// Found a NAL unit with 4-byte startcode
if(buf[4] & 0x1F == 0x5)
{
// Found a reference frame, do something with it
}
break;
}
buf++;
}
}

关于parsing - h264 引用帧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10946496/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com