使用FFMpeg iOS解码相机流视频帧时出错

我有一个应用程序,其中我解码来自IP摄像头的视频帧,但方法avcodec_decode_video2(m_pCodecCtx, m_pFrame, &consumed_bytes, &avpkt); 目前在avcodec.h生成bad_access,我无法弄清楚什么是错的。

这个应用程序与旧库FFMpeg工作正常,但通过苹果政策,为了发布它支持arm64的应用程序,所以我更新了我的库以支持arm64,之后发生了此问题。

这是截图

在这里输入图像描述

虽然bad_access应用程序正在生成以下日志:

[h264 @ 0x1071400] sps_id 12 out of range
[h264 @ 0x1071400] pps_id 417 out of range
[h264 @ 0x1071400] sps_id 3 out of range
[h264 @ 0x1071400] sps_id 32 out of range
[h264 @ 0x1071400] sps_id 6 out of range
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] sps_id 32 out of range
[h264 @ 0x1071400] sps_id 1 out of range
[h264 @ 0x1071400] sps_id 3 out of range
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] sps_id 32 out of range
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] sps_id 1 out of range
[h264 @ 0x1071400] sps_id 1 out of range
[h264 @ 0x1071400] sps_id 1 out of range
[h264 @ 0x1071400] sps_id 1 out of range
[h264 @ 0x1071400] sps_id 1 out of range
[h264 @ 0x1071400] sps_id 1 out of range
[h264 @ 0x1071400] sps_id 1 out of range
[h264 @ 0x1071400] sps_id 2 out of range
[h264 @ 0x1071400] sps_id 2 out of range
[h264 @ 0x1071400] sps_id 2 out of range
[h264 @ 0x1071400] sps_id 2 out of range
[h264 @ 0x1071400] sps_id 2 out of range
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] sps_id 32 out of range
[h264 @ 0x1071400] sps_id 3 out of range
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] sps_id 1 out of range
[h264 @ 0x1071400] sps_id 1 out of range
[h264 @ 0x1071400] sps_id 1 out of range
[h264 @ 0x1071400] sps_id 1 out of range
[h264 @ 0x1071400] sps_id 1 out of range
[h264 @ 0x1071400] sps_id 1 out of range
[h264 @ 0x1071400] sps_id 1 out of range
[h264 @ 0x1071400] sps_id 2 out of range
[h264 @ 0x1071400] sps_id 2 out of range
[h264 @ 0x1071400] sps_id 2 out of range
[h264 @ 0x1071400] sps_id 2 out of range
[h264 @ 0x1071400] sps_id 2 out of range
[h264 @ 0x1071400] pps_id 418 out of range
[h264 @ 0x1071400] Partitioned H.264 support is incomplete
[h264 @ 0x1071400] sps_id 6 out of range
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] sps_id 1 out of range
[h264 @ 0x1071400] non-existing PPS 3 referenced
[h264 @ 0x1071400] decode_slice_header error
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] slice type 10 too large at 0 0
[h264 @ 0x1071400] decode_slice_header error
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] non-existing PPS 2 referenced
[h264 @ 0x1071400] decode_slice_header error
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] slice type 29 too large at 0 0
[h264 @ 0x1071400] decode_slice_header error
[h264 @ 0x1071400] sps_id 2 out of range
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] sps_id 0 out of range
[h264 @ 0x1071400] slice type 32 too large at 0 0
[h264 @ 0x1071400] decode_slice_header error
[h264 @ 0x1071400] slice type 32 too large at 0 0
[h264 @ 0x1071400] decode_slice_header error
[h264 @ 0x1071400] slice type 32 too large at 0 0
[h264 @ 0x1071400] decode_slice_header error
[h264 @ 0x1071400] slice type 32 too large at 0 0

完整的错误日志: https //drive.google.com/file/d/0B-Nh7ci6wLX0OVlxaXV4aGpJems/view?usp =分享

崩溃日志: http : //crashes.to/s/6765d63b540

注意:如果您需要其他东西,请发表评论。


我解决了我的问题,问题是使用折旧方法avcodec_alloc_frame()

我在构造函数中使用下面的代码

    m_pCodecCtx = avcodec_alloc_context3(m_pCodec);
    if(m_pCodecCtx == NULL)
    {
        NSLog(@"if(pCodecCtx == NULL)n");
        return ;
    }  
   [g_Lock lock];
    //¥Úø™codec°£»Áπ˚¥Úø™≥…𶵃ª∞£¨∑÷≈‰AVFrame£     
    if(avcodec_open2(m_pCodecCtx, m_pCodec, NULL) >= 0)     
    {     
        m_pFrame = avcodec_alloc_frame();   /* Allocate video frame   */

    }
    [g_Lock unlock];

然后我最终更新了我的头文件,之后我得到了有关方法avcodec_alloc_frame()折旧的警告,于是我将它更新为av_frame_alloc() ,它的工作完美无瑕!

链接地址: http://www.djcxy.com/p/30793.html

上一篇: Error while decoding camera stream video frame using FFMpeg iOS

下一篇: Verify gpg signature in Go openpgp