Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL
Help

Using the Camera > Video Customisation - Pg. 65

Feedback: 0 Comments on this Section

After doing so we can modify the imagePickerController:didFinishPickingMediaWithInfo: method to use the FFmpeg library to obtain its thumbnail as follows; -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { if( [info objectForKey:@"UIImagePickerControllerMediaType"] == kUTTypeMovie ) { NSString *tempFilePath = [[info objectForKey:UIImagePickerControllerMediaURL] path]; VideoFrameExtractor *video = [[VideoFrameExtractor alloc] initWithVideo:tempFilePath]; [video seekTime:1.0]; BOOL result = [video stepFrame]; imageView.image = video.currentImage; } else { imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"]; } [self dismissModalViewControllerAnimated:YES]; } Remember you'll also need to, #import "VideoFrameExtractor.h" at the top of your MediaController class. However with that done make sure you've saved your changes, and click on the Build and Go Button in the Xcode toolbar to compile and deploy your application to your iPhone device. Remember that we could not compile an x86 version of the FFmpeg library so you'll have to test your code directly on your device. If everything works okay you should be able to capture a movie and a thumbnail will appear as before. This time however we're Video Customisation If you are capturing video you can make some video-specific customizations using the videoQuality and videoMaximumDuration properties of the UIImagePickerController class. pickerController.videoQuality = UIImagePickerControllerQualityTypeLow; pickerController.videoMaximumDuration = 90; // Maximum 90 seconds duration Table 4-3 illustrates the expected sizes of a typical 90 second movie file for the three possible image quality levels, which defaults to UIImagePickerControllerQualityTypeMedium. Table 4-3. Size of 90 seconds duration video for different quality settings Quality UIImagePickerControllerQualityTypeLow UIImagePickerControllerQualityTypeMedium UIImagePickerControllerQualityTypeHigh Size 1.8MB 8.4MB 32MB The maximum, and default, value for the videoMaximumDuration property is 10 minutes. Users are forced to trim longer video to match the duration you request.