I am trying to trim a video using UIVideoEditorController. After cropping or saving, using the UIVideoEditorController lost my video resolution. I used the UIImagePickerController
to shoot video with the set resolution up to UIImagePickerControllerQualityTypeIFrame1280x720
and set the URL in the UIVideoEditorController with the videoQuality property (iPhone 5) of the UIImagePickerControllerQualityTypeIFrame1280x720
. The same effect when I use the AVFoudation framework to capture video. Why am I losing permission? My code is:
if ([UIVideoEditorController canEditVideoAtPath:self.videoPath]) { //video quality 1280x720 self.editor = [UIVideoEditorController new]; self.editor.videoPath = self.videoPath; self.editor.videoMaximumDuration = 180.0;
in the delegate:
- (void)videoEditorController:(UIVideoEditorController *)editor didSaveEditedVideoToPath:(NSString *)editedVideoPath { [self removeImage:editor.videoPath]; [editor dismissViewControllerAnimated:YES completion:^{ }]; #if DEBUG AVAssetTrack *videoTrack = nil; AVURLAsset *asset = [AVAsset assetWithURL:[NSURL fileURLWithPath:editedVideoPath]]; NSArray *videoTracks = [asset tracksWithMediaType:AVMediaTypeVideo]; CMFormatDescriptionRef formatDescription = NULL; NSArray *formatDescriptions = [videoTrack formatDescriptions]; if ([formatDescriptions count] > 0) formatDescription = (__bridge CMFormatDescriptionRef)[formatDescriptions objectAtIndex : 0]; if ([videoTracks count] > 0) videoTrack = [videoTracks objectAtIndex:0]; CGSize trackDimensions = { .width = 0.0, .height = 0.0, }; trackDimensions = [videoTrack naturalSize]; int width = trackDimensions.width; int height = trackDimensions.height; DLog(@"Resolution = %d X %d", width, height); <- 640x320 #endif if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(editedVideoPath)) { [self convertVideo:[NSURL fileURLWithPath:editedVideoPath]]; } else { DLog(@"cannot save video on path %@", editedVideoPath); } }
source share