0

I am developing an application which records the video and saves that video in database, now i want to reduce the resolution and bitrate/sec of recorded video how i can do that. any help on it.

thank you.

Shiva Reddy
  • 456
  • 1
  • 7
  • 26
  • is not more easy, before records the video choose the resolution and bitrate? – anvd Feb 13 '11 at 05:00
  • Thank you for quick reply Fel, How can i choose the resolution before recording the video, currently i am using picker.videoQuality = UIImagePickerControllerQualityTypeLow and i am getting size 3MB for 1min, if i use medium quality i am getting 13MB, i need <1MB or 1.5 for 1min. – Shiva Reddy Feb 13 '11 at 06:48
  • possible duplicate of [iPhone:Programmatically compressing recorded video to share?](http://stackoverflow.com/questions/5687341/iphoneprogrammatically-compressing-recorded-video-to-share) – Rajesh Loganathan Nov 27 '13 at 09:50

1 Answers1

1

Try this:

- (void)convertVideoToLowQuailtyWithInputURL:(NSURL*)inputURL 
                                   outputURL:(NSURL*)outputURL 
                                     handler:(void (^)(AVAssetExportSession*))handler
{
    [[NSFileManager defaultManager] removeItemAtURL:outputURL error:nil];
    AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:inputURL options:nil];
    AVAssetExportSession *session = [[AVAssetExportSession alloc] initWithAsset: urlAsset presetName:AVAssetExportPresetLowQuality];
    session.outputURL = storeVideo;
    session.outputFileType = AVFileTypeQuickTimeMovie;
    [session exportAsynchronouslyWithCompletionHandler:^(void) 
    {
        handler(session);

    }];
}

For picking video from gallery

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

{   
    NSURL *getVideo = [info objectForKey:UIImagePickerControllerMediaURL];
    NSURL *storeVideo = [NSURL fileURLWithPath:@"/videos/welcome.mov"];
    [self convertVideoToLowQuailtyWithInputURL:videoURL outputURL:outputURL handler:^(AVAssetExportSession *session)
     {
         if (session.status == AVAssetExportSessionStatusCompleted)
         {
             // Success
         }
         else
         {
             // Error Handing

         }
     }];

Use following item to change resolution:

UIImagePickerControllerQualityTypeHigh    
UIImagePickerControllerQualityType640x480 
UIImagePickerControllerQualityTypeMedium    // default 
UIImagePickerControllerQualityTypeLow  
Rajesh Loganathan
  • 11,129
  • 4
  • 78
  • 90