- (void)saveMovieToCameraRoll
{
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library writeVideoAtPathToSavedPhotosAlbum:movieURL
completionBlock:^(NSURL *assetURL, NSError *error) {
if (error)
[self showError:error];
else
[self removeFile:movieURL];
dispatch_async(movieWritingQueue, ^{
recordingWillBeStopped = NO;
self.recording = NO;
[self.delegate recordingDidStop];
});
}];
[library release];
}
這是蘋果示例rosywriter的代碼片段。 Sould工作。
movieURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), @"Movie.MOV"]];
[movieURL retain];
上述行爲視頻創建文件和路徑。
- (void) startRecording
{
dispatch_async(movieWritingQueue, ^{
if (recordingWillBeStarted || self.recording)
return;
recordingWillBeStarted = YES;
// recordingDidStart is called from captureOutput:didOutputSampleBuffer:fromConnection: once the asset writer is setup
[self.delegate recordingWillStart];
// Remove the file if one with the same name already exists
[self removeFile:movieURL];
// Create an asset writer
NSError *error;
assetWriter = [[AVAssetWriter alloc] initWithURL:movieURL fileType:(NSString *)kUTTypeQuickTimeMovie error:&error];
if (error)
[self showError:error];
});
}
此功能用於使用avassetwriter開始將視頻錄製到該movieURL文件中。
來源
2012-04-03 11:08:48
jkr
[UISaveVideoAtPathToSavedPhotosAlbum](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIKitFunctionReference/Reference/reference.html#//apple_ref/c/func/UISaveVideoAtPathToSavedPhotosAlbum) – Hemang 2012-04-03 10:36:05