我正在尝试进行屏幕捕获并写入视频文件。
assetWriterTimer = [NSTimer scheduledTimerWithTimeInterval:0.5
target:self
selector:@selector (writeSample:)
userInfo:nil
repeats:YES] ;
-(void) writeSample: (NSTimer*) _timer
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//capture and save image to video
});
}
为了停止记录,我写
-(void) stopRecording
{
[assetWriterTimer invalidate];
assetWriterTimer = nil;
[assetWriterTimer release];
[assetWriter finishWritingWithCompletionHandler:^(){
NSLog (@"finished writing completion handler");
}];
NSLog (@"finished writing");
}
但是,我大多会收到此错误和应用程序崩溃。我应该怎么做?
-[AVAssetWriter finishWriting] 状态为 2' 时无法调用方法