c – 使用FFMpeg iOS解码摄像机流视频帧时出错

我有一个应用程序,其中我解码来自ip camera的视频帧,但方法avcodec_decode_video2(m_pCodecCtx,m_pFrame,& consume_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=sharing

崩溃日志: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(),它运行完美!

相关文章

本程序的编译和运行环境如下(如果有运行方面的问题欢迎在评...
水了一学期的院选修,万万没想到期末考试还有比较硬核的编程...
补充一下,先前文章末尾给出的下载链接的完整代码含有部分C&...
思路如标题所说采用模N取余法,难点是这个除法过程如何实现。...
本篇博客有更新!!!更新后效果图如下: 文章末尾的完整代码...
刚开始学习模块化程序设计时,估计大家都被形参和实参搞迷糊...