在录制视频之前调用相机视图时,我已经实现了叠加视图。pickerController.cameraOverlayView =myOverlay;录制视频并通过电子邮件共享后,可以进行视频录制并将视频保存到“相册”中。如果我将视频质量用作“高质量”,则录制的视频已经变得很大。例如,如果我以高质量录制视频30秒钟,则录制的视频已变为30-40 mb。pickerController.videoQuality = UIImagePickerControllerQualityTypeHigh;我如何编程才能在共享之前压缩高质量的录制视频,就像Apple对内置视频录制器的处理方式一样?请指导我解决此问题。谢谢!更新:这是我最近正在尝试的方法,但仍然没有成功:我想压缩录制的音频,并将它们录制到didFinishPickingMediaWithInfo并将其实际的视频路径本身存储在同一相册中,而不是其他位置。当我从照片库中选取时,我测试了将相同的视频压缩到非常小的尺寸,但是虽然我使用了下面的AVAssetExportSession代码,但是从相机拍摄并通过didFinishPickingMediaWithInfo来的相同视频未压缩。- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];if ([mediaType isEqualToString:(NSString *)kUTTypeMovie]){ NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL]; NSString *urlPath = [videoURL path]; if ([[urlPath lastPathComponent] isEqualToString:@"capturedvideo.MOV"]) { if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum (urlPath)) { [self copyTempVideoToMediaLibrary :urlPath]; } else { NSLog(@"Video Capture Error: Captured video cannot be saved...didFinishPickingMediaWithInfo()"); } } else { NSLog(@"Processing soon to saved photos album...else loop of lastPathComponent..didFinishPickingMediaWithInfo()"); }} [self dismissModalViewControllerAnimated:YES];}- (void)copyTempVideoToMediaLibrary :(NSString *)videoURL { dispatch_queue_t mainQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);dispatch_async(mainQueue, ^{ ALAssetsLibrary *library = [[[ALAssetsLibrary alloc] init] autorelease]; ALAssetsLibraryWriteVideoCompletionBlock completionBlock = ^(NSURL *assetURL, NSError *error) { NSLog(@"Saved URL: %@", assetURL); NSLog(@"Error: %@", error);
3 回答
- 3 回答
- 0 关注
- 698 浏览
添加回答
举报
0/150
提交
取消