我正在使用以下代码来创建给定图像数组的视频。一切正常。代码在串行队列上运行。当状态应用程序从后台更改为前台时,此代码在 CVBufferRelease(buffer) 上崩溃。我还验证了缓冲区不指向空值。
知道如何解决这个问题吗?
UIImage *image = [UIImage imageWithData:imgFrameData];
CVPixelBufferRef buffer = NULL;
buffer = [self newPixelBufferFromCGImage:[image CGImage] andSize:CGSizeMake(frameSize, frameSize)];
BOOL append_ok = NO;
while (!append_ok){
if (adaptor.assetWriterInput.readyForMoreMediaData)
{
CMTime frameTime = CMTimeMake(i*timeBetweenFrame,(int32_t) TIMESCALE);
CMTimeShow(frameTime);
append_ok = [adaptor appendPixelBuffer:buffer withPresentationTime:frameTime];
if(buffer)
{
CVBufferRelease(buffer);
}
[NSThread sleepForTimeInterval:0.05];
}
else
{
[NSThread sleepForTimeInterval:0.1];
}
}