I have the following problem - I am trying to create an app that records video, then save it to the camera roll and after that I am uploading that video to the web. The problem is that the only supported format is "mp4", but my videos are "mov".
So my question is how to save video from camera in "mp4" format, or save it in "mov" and then convert it to "mp4".
Here's my code:
this is how I open the camera:
picker = [[UIImagePickerController alloc] init]; picker.sourceType = UIImagePickerControllerSourceTypeCamera; picker.delegate = self; picker.showsCameraControls = YES; picker.allowsEditing = YES; picker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil]; [self presentViewController:picker animated:YES completion:nil];
this is how I save the video:
NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType]; if (CFStringCompare ((__bridge_retained CFStringRef) mediaType, kUTTypeMovie, 0) == kCFCompareEqualTo) { NSString *moviePath = [[info objectForKey:UIImagePickerControllerMediaURL] path]; videoURL = info[UIImagePickerControllerMediaURL]; if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(moviePath)) { UISaveVideoAtPathToSavedPhotosAlbum(moviePath, self, nil, nil); } } [nextScreenButton setTitle:@"ПРОДЪЛЖИ" forState:UIControlStateNormal]; [self dismissViewControllerAnimated:YES completion:nil];
Thanks in advance!
You are doing right thing.. Now you need to convert this mov file to mp4 as below.
Here you can specify video type, quality and output url for compress video.
See below methods:
Yes, you can compress video using
AVAssetExportSession
. Here, I saved compress video todocument directory
of application. You can check detail working of this in this code.If you have still issues, then refer this and this.
Here is the code to convert mov video into mp4 for swift
Swift 3