Why can videos selected using the high and medium settings of the UIImagePickerController lead to the same quality attributes based on the results?

Why are videos selected with UIImagePickerController high and medium image quality settings selected, resulting in exactly the same video attributes, at least on devices like iPhone4 and iPad3?

More details:

We use UIImagePickerController so that users of our application can select images or videos from the photo library and then transfer them to their servers. We allow users to select high, medium, or low quality video quality that we directly map to the video stream constants UIImagePickerControllerQualityTypeHigh, UIImagePickerControllerQualityTypeMedium and UIImagePickerControllerQualityTypeLow.

When 10 seconds or so is selected on the 3GS (iOS 5.0) screen, taken outside of our camera application, we see a clear difference with each quality parameter, for example:

  • low: 226 KB on 144x192, codec: AAC H.264
  • medium: 1.1MB on 360x480, codec: AAC H.264
  • high: 5 MB at 480x640, codec: AAC H.264

When we try to do the same on iPhone4 or iPad3 (we have convenient devices, I'm not sure that this only happens on these devices), we see that a low setting generates an equivalent low-resolution result, but a high and medium setting gives us those same results, something like this:

  • low: 194 KB on 144x192, codec: AAC H.264
  • environment: 2.87MB at 720x1280, codec: AAC H.264
  • high: 2.87MB at 720x1280, codec: AAC H.264

(Note that medium and high results are identical.)

The original from the device is 12.8 MB at 720x1280, codec: AAC H.264 with a higher transfer rate.

Can anyone explain what is going on here? I would like for us to be able to explain this to our customers, even better point out something in the Apple document that covers this.

Thanks in advance for your help ...

+6
source share
1 answer

Video quality setting applies only when capturing video and not selecting them from the video picker. This parameter is clearly indicated below in the capture settings section.

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html

You can use the code below to export the video in its original form. Just pass the URL value of the selected video and the function will return the path for the exported video.

+(NSString*) videoAssetURLToTempFile:(NSURL*)url { NSString * surl = [url absoluteString]; NSString * ext = [surl substringFromIndex:[surl rangeOfString:@"ext="].location + 4]; NSTimeInterval ti = [[NSDate date]timeIntervalSinceReferenceDate]; NSString * filename = [NSString stringWithFormat: @"%f.%@",ti,ext]; NSString * tmpfile = [NSTemporaryDirectory() stringByAppendingPathComponent:filename]; NSURL *outputURL = [NSURL fileURLWithPath:tmpfile]; AVURLAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil]; AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetHighestQuality]; exportSession.outputURL = outputURL; exportSession.shouldOptimizeForNetworkUse = YES; exportSession.outputFileType = AVFileTypeQuickTimeMovie; [exportSession exportAsynchronouslyWithCompletionHandler:^(void) { NSLog(@"Export Complete %d %@ %@", exportSession.status, exportSession.error, outputURL); [exportSession release]; }]; return tmpfile; } 
+5
source

Source: https://habr.com/ru/post/914275/


All Articles