use*_*100 15 avfoundation ios avassetwriter
似乎在iOS 6模拟器上打破了finishWriting - 它永远挂起.它现在已被弃用,并被新的finishWritingWithCompletionHandler取代: - 它也永远不会调用处理程序.
在运行iOS 6的真实设备上,这样可以正常工作.同样在之前的iOS模拟器中它运行得很好.看起来像iOS 6模拟器中的错误.
有其他人遇到这个或可以证明我错了吗?
好的,在模拟器上找到了解决方法。
看起来 stop 会使视频处理线程死锁,因此解决方法是在主线程中调用 stop :
// in iOS6 Simulator this blocks the video processing thread call back in UI thread.
// BOOL stop = [assetWriter finishWriting];
[self performSelectorOnMainThread:@selector(stopInOtherThread) withObject:nil];
-(void)stopInOtherThread{
//Stop doesn't block in MainThread
BOOL stop = [assetWriter finishWriting];
NSLog(@" assetWriter finishWriting :%d",stop);
}
Run Code Online (Sandbox Code Playgroud)
此解决方法似乎不适用于 finishWritingWithCompletionHandler
我会尝试看看是否可以在 Apple 上提出错误。