這是作家開始代碼
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];
}
可以ü請與示例代碼解釋更 – mychar
[assetWriter finishWritingWithCompletionHandler:^(){ } completionHandler:^(BOOL完成){如果(完成)NSLog(@「完成的寫作」);} } ];你可以這樣解釋,這段代碼有錯誤 – mychar
[assetWriter finishWritingWithCompletionHandler:^(){ NSLog(@「finished writing」); }];這一個dosen't工作,我嘗試it.It崩潰的應用程序,請幫助我 – mychar