Tôi đang nhận inputurl [info objectForKey:UIImagePickerControllerMediaURL]
từ phương thức của UIImagepickercontroller's didFinishPickingMediaWithInfo
.UIImagepickercontroller: chuyển sang lỗi video chất lượng thấp
NSURL *inputURL = [NSURL URLWithString:inputurlstring];
Tôi cho outputurl từ mã này
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *videoPath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,@"capturedvideo.MOV"];
NSURL *outputURL = [NSURL fileURLWithPath:videoPath];
tôi đã sử dụng đoạn mã sau để có được video chất lượng thấp
- (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);
}
}];
}
Tôi nhận được lỗi sau khi tôi sử dụng các file lớn duy nhất. Bởi vì khi tôi sử dụng tệp video kích thước nhỏ, tôi không nhận được bất kỳ lỗi nào.
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}
Bạn đang cắt tỉa video lớn? Dường như trang trí đang được lưu trữ trong một thư mục riêng tư. –
Tôi đang chuyển đổi thành chất lượng thấp và tôi đang lưu trữ trong thư mục tài liệu @AlbertRenshaw – Suresh
Tại sao bạn không bỏ qua chuyển đổi và đặt thuộc tính videoQuality trên UIImagePickerController thành UIImagePickerControllerQualityTypeLow? –