ios - AVAssetsWriter CVBufferRelease(buffer);导致崩溃
<p><p>AVAssetsWriter CVBufferRelease(buffer);导致“线程 1:EXC_BAD_ACCESS (code=1, address = 0x1ac05beb8) 崩溃。</p>
<p>我正在开发一款将图像组合成视频的应用。它工作得很好,除非用户关闭应用程序或应用程序崩溃以某种方式中断附加过程。下次启动应用程序时,会发生这种崩溃,只能通过删除并重新安装应用程序来解决。下面是我用来附加图像的代码。当崩溃发生时,CVBufferRelease(buffer);由 Xcode 突出显示。</p>
<p>提前感谢您的帮助。</p>
<pre><code>CVPixelBufferRef buffer = NULL;
//convert uiimage to CGImage.
int frameCount = 0;
for(UIImage * img in imageArray)
{
buffer = andSize:size];
BOOL append_ok = NO;
int j = 0;
while (!append_ok && j < 30)
{
if (adaptor.assetWriterInput.readyForMoreMediaData)
{
printf("appending %d attemp %d\n", frameCount, j);
CMTime frameTime = CMTimeMake(frameCount,(int32_t) kRecordingFPS);
append_ok = ;
if(buffer)
CVBufferRelease(buffer);
;
}
else
{
printf("adaptor not ready %d, %d\n", frameCount, j);
;
}
j++;
}
if (!append_ok) {
printf("error appending image %d times %d\n", frameCount, j);
}
frameCount++;
}
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>经过多次反复,我设法发现了问题。我忽略了这样一个事实,即在每次写作开始时都需要清除附加视频的路径。</p>
<pre><code>if([ fileExistsAtPath:path]){
[ removeItemAtPath:path error:&error];
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - AVAssetsWriter CVBufferRelease(buffer);导致崩溃,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/22728543/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/22728543/
</a>
</p>
页:
[1]