UIVideoEditorController allwas change the video resolution
Asked Answered
E

0

7

I am trying to trim video using UIVideoEditorController. After trimming or saving, using UIVideoEditorController lost my video resolution. I used UIImagePickerController to taking video with set resolution to UIImagePickerControllerQualityTypeIFrame1280x720 and set the url path to UIVideoEditorController with property videoQuality to (iPhone 5) UIImagePickerControllerQualityTypeIFrame1280x720. That same efect when I use AVFoudation framework to capture video. Why I lost resolution? My code:

  if ([UIVideoEditorController canEditVideoAtPath:self.videoPath]) {
//video quality 1280x720
  self.editor = [UIVideoEditorController new];
  self.editor.videoPath = self.videoPath;
  self.editor.videoMaximumDuration = 180.0;
  #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_5_0
  self.editor.videoQuality =
      UIImagePickerControllerQualityTypeIFrame1280x720;

#elif __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0
  self.editor.videoQuality =
      UIImagePickerControllerQualityType640x480; // VGA quality
#endif

  self.editor.delegate = self;

  [self.navigationController presentViewController:self.editor
                                          animated:NO
                                        completion:nil];
} else {
  DLog(@"can't edit video at %@", self.videoPath);
}

in 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);
  }
}
Eardrum answered 1/12, 2014 at 18:31 Comment(5)
Hello Quba88 Did you found any solution!Cookie
Sorry no. I used this controll and trim a video using AVAssetExportSession. Good luckEardrum
I ended up using same control. Such a shame.Cookie
It's still not working.Hexose
It is now end of 2023 and this is still not working? This cannot really be true. Does nobody have any idea how to solve this?Thay

© 2022 - 2024 — McMap. All rights reserved.