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. a开发者_开发技巧ny help on it.
thank you.
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
精彩评论