UIImagepickercontroller:转换为低质量的视频错误 [英] UIImagepickercontroller: converting to low quality video error
问题描述
我正在从UIImagepickercontroller的didFinishPickingMediaWithInfo
方法获取输入URL [info objectForKey:UIImagePickerControllerMediaURL]
.
I am getting inputurl [info objectForKey:UIImagePickerControllerMediaURL]
from UIImagepickercontroller's didFinishPickingMediaWithInfo
's method.
NSURL *inputURL = [NSURL URLWithString:inputurlstring];
我要从此代码中提供outputurl
I am giving outputurl from this code
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *videoPath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,@"capturedvideo.MOV"];
NSURL *outputURL = [NSURL fileURLWithPath:videoPath];
我使用以下代码来获取低质量的视频
I used the following code to get low quality video
- (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);
}
}];
}
仅使用大文件时出现以下错误.因为当我使用小尺寸的视频文件时,我没有得到任何错误.
I am getting following error when I use large files only. Because when I use small size video file I did not get any 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}
推荐答案
上面的代码是完美的作品.唯一的变化是inputURL.
the above code is perfectly works. the only change is inputURL.
在将inputURL更改为fileURLWithPath之后:
after I changed the inputURL to fileURLWithPath:
NSURL *inputURL = [NSURL fileURLWithPath:inputurlstring];
现在它可以完美工作了.
Now its perfectly works.
这篇关于UIImagepickercontroller:转换为低质量的视频错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!