Error decoding camera video stream using FFMpeg iOS

I have an application in which I decode video fragments coming from an ip camera, but the avcodec_decode_video2(m_pCodecCtx, m_pFrame, &consumed_bytes, &avpkt); method avcodec_decode_video2(m_pCodecCtx, m_pFrame, &consumed_bytes, &avpkt); present in avcodec.h , generating bad_access, I can not understand what is wrong.

This application works fine with the old FFMpeg libraries, but according to Apple's policy, to publish the application, it supports arm64, so I updated my libraries to support arm64, and after that there was this problem.

Here is a screenshot

enter image description here

While the bad_access application creates the following log:

 [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 

Full error log: https://drive.google.com/file/d/0B-Nh7ci6wLX0OVlxaXV4aGpJems/view?usp=sharing

Crash Log: http://crashes.to/s/6765d63b540

Note. If you need anything else, please comment.

+7
c ++ ios ffmpeg ip-camera
source share
1 answer

I solved the problem, the problem was in the avcodec_alloc_frame() method.

I used the following code in the constructor

  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]; 

Then I eventually updated my header files, after which I received warnings about the depreciation of the avcodec_alloc_frame() method, so I updated it to av_frame_alloc() and it worked flawlessly!

+3
source share

All Articles