我从UIImagepickercontroller的didFinishPickingMediaWithInfo
的方法获取inputurl [info objectForKey:UIImagePickerControllerMediaURL]
。UIImagepickercontroller:转换为低质量视频错误
NSURL *inputURL = [NSURL URLWithString:inputurlstring];
我从这个代码
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *videoPath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,@"capturedvideo.MOV"];
NSURL *outputURL = [NSURL fileURLWithPath:videoPath];
给outputurl我用下面的代码来获得低质量的视频
- (void)convertVideoToLowQuailtyWithInputURL:(NSURL*)inputURL
outputURL:(NSURL*)outputURL
handler:(void (^)(AVAssetExportSession*))handler
{
[[NSFileManager defaultManager] removeItemAtURL:outputURL error:nil];
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:inputURL options:nil];
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetLowQuality];
exportSession.outputURL = outputURL;
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
[exportSession exportAsynchronouslyWithCompletionHandler:^(void)
{
if (exportSession.status == AVAssetExportSessionStatusCompleted)
{
printf("completed\n");
}
else
{
printf("error\n");
NSLog(@"error is %@",exportSession.error);
}
}];
}
我收到以下错误,当我只用大文件。因为当我使用小尺寸视频文件时,我没有收到任何错误。
Error Domain=NSURLErrorDomain Code=-1 "unknown error" UserInfo=0x616d890
{NSErrorFailingURLStringKey=/private/var/mobile/Applications/EE1E6701-EED0-4830-BD1D-7366680713C0/tmp//trim.7mL7VS.MOV, NSErrorFailingURLKey=/private/var/mobile/Applications/EE1E6701-EED0-4830-BD1D-7366680713C0/tmp//trim.7mL7VS.MOV, NSLocalizedDescription=unknown error, NSUnderlyingError=0x2d1460 "The operation couldn’t be completed. (OSStatus error -12935.)", NSURL=/private/var/mobile/Applications/EE1E6701-EED0-4830-BD1D-7366680713C0/tmp//trim.7mL7VS.MOV}
你是否正在修剪大型视频?它看起来像修剪存储在一个私人文件夹。 – 2013-02-14 13:13:56
我转换为低质量,我存储在文档目录中@AlbertRenshaw – Suresh 2013-02-15 04:44:54
为什么不跳过转换并将UIImagePickerController上的videoQuality属性设置为UIImagePickerControllerQualityTypeLow? – 2013-02-17 03:38:16