Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

查找视频帧判断有问题 #297

Open
HalcyonHuang opened this issue Jul 22, 2023 · 5 comments
Open

查找视频帧判断有问题 #297

HalcyonHuang opened this issue Jul 22, 2023 · 5 comments

Comments

@HalcyonHuang
Copy link

HalcyonHuang commented Jul 22, 2023

我的视频流里面,经常出现在一个视频帧中间有 xx xx 0 0 0 0 0 0 0 0 0 1 6 5 ff ff a0 81 6d 38 4e 99 这样的数据排列 。
代码里面的查找视频帧函数会误判断为 NAL_SEI 帧,从而吧一个完整的视频帧分成两个帧。但实际上只有一个帧。

int mpeg_h264_find_nalu(const uint8_t* p, size_t bytes, size_t* leading)
{
    size_t i, zeros;
    for (zeros = i = 0; i + 1 < bytes; i++)
    {
        if (0x01 == p[i] && zeros >= 2) //这里判断出错
        {
            assert(i >= zeros);
            if (leading)
                *leading = (zeros > 2 ? 3 : zeros) + 1; // zeros + 0x01
            return (int)(i + 1);
        }

        zeros = 0x00 != p[i] ? 0 : (zeros + 1);
    }

    return -1;
}

我的修改方法是吧判断条件 if (0x01 == p[i] && zeros >= 2) 改成 if (0x01 == p[i] && (zeros == 3 || zeros == 4)) 即可。

@ireader
Copy link
Owner

ireader commented Jul 25, 2023

视频帧中间出现0 0 0 1, 按照规范需要插入防冲突字符, 修改成0 0 3 1

你的视频流从什么设备生成的, 方便的话麻烦用wireshark抓一个完整包, 我确认下上下文信息。

@HalcyonHuang
Copy link
Author

target_5_48.1 (1).zip

@HalcyonHuang
Copy link
Author

HalcyonHuang commented Aug 2, 2023

@ireader 视频流是对接的大疆的无人机

@ireader
Copy link
Owner

ireader commented Aug 3, 2023

怎么过滤出rtp数据流?

@HalcyonHuang
Copy link
Author

253541527-bcceb57e-7eac-48b5-8ddd-0ec5fef5424c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants