我使用AVAssetWriter对图像集中的视频进行编码:
[assetWriter finishWriting];此方法会在iOS 6中生成警告。
[assetWriter finishWritingWithCompletionHandler:<#^(void)handler#>];这就是我应该如何在iOS 6中应用它。有人能帮助我应用它吗
发布于 2012-11-08 19:21:10
你不需要检查它是否完成了。完成处理程序是一个块。当写入完成时,它将被系统调用。试试看。
[assetWriter finishWritingWithCompletionHandler:^(){
NSLog (@"finished writing");
}];发布于 2012-11-10 12:22:00
这是编写器开始代码
NSURL *movieURL = [NSURL fileURLWithPath:myPathDocs1];
NSError *movieError = nil;
[assetWriter release];
assetWriter = [[AVAssetWriter alloc] initWithURL:movieURL
fileType: AVFileTypeQuickTimeMovie
error: &movieError];
NSDictionary *assetWriterInputSettings = [NSDictionary dictionaryWithObjectsAndKeys:
AVVideoCodecH264, AVVideoCodecKey,
[NSNumber numberWithInt:FRAME_WIDTH], AVVideoWidthKey,
[NSNumber numberWithInt:FRAME_HEIGHT], AVVideoHeightKey,
nil];
assetWriterInput = [AVAssetWriterInput assetWriterInputWithMediaType: AVMediaTypeVideo
outputSettings:assetWriterInputSettings];
assetWriterInput.expectsMediaDataInRealTime = YES;
[assetWriter addInput:assetWriterInput];
[assetWriterPixelBufferAdaptor release];
assetWriterPixelBufferAdaptor = [[AVAssetWriterInputPixelBufferAdaptor alloc]
initWithAssetWriterInput:assetWriterInput
sourcePixelBufferAttributes:nil];
[assetWriter startWriting];
firstFrameWallClockTime = CFAbsoluteTimeGetCurrent();
[assetWriter startSessionAtSourceTime: CMTimeMake(0, TIME_SCALE)];
// start writing samples to it
[assetWriterTimer release];
assetWriterTimer = [NSTimer scheduledTimerWithTimeInterval:1.0f/60.0f
target:self
selector:@selector (writeSample:)
userInfo:nil
repeats:YES] ;这是编写器停止代码
if (isRecording) {
isRecording = NO;
[_session stopRunning];
[assetWriterTimer invalidate];
assetWriterTimer = nil;
[assetWriter finishWritingWithCompletionHandler:^(){
NSLog (@"finished writing");
}];
[self loadOvelay];
}https://stackoverflow.com/questions/13287374
复制相似问题