Video sharing
Want to achieve a video on iphone, upload to the cloud to share to mobile friends.
Technology implementation
Video compression. The video of the iphone is very large, a few seconds on a few 10 trillion files, need to do compression, the original consideration with ffmpeg, installation is more complex, there are many tutorials on the web, but there are certain risks when passing AppStore audit.
The first thing to do is click on the code to start recording:
if([Uiimagepickercontroller Issourcetypeavailable:uiimagepickercontrollersourcetypecamera]) {UIImagePic Kercontroller*imagepicker =[[Uiimagepickercontroller alloc] init]; Imagepicker.videoquality= uiimagepickercontrollerqualitytypeiframe960x540;//Video quality settingsImagepicker.sourcetype=Uiimagepickercontrollersourcetypecamera; Imagepicker.Delegate=Self ; Imagepicker.allowsediting=YES; Imagepicker.videomaximumduration=300.0f;//set maximum recording 5 minutesImagepicker.mediatypes= [Nsarray arraywithobject:@"Public.movie"]; [Self presentviewcontroller:imagepicker animated:yes completion:^{ }]; }
Callback method after recording:
- (void) Imagepickercontroller: (Uiimagepickercontroller *) Picker Didfinishpickingmediawithinfo: (NSDictionary *) info{Nsurl*url =[Info Objectforkey:uiimagepickercontrollermediaurl]; NSLog (@"------%@", URL); NSString*appdocumentpath =[Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES) lastobject]; Nsurl*uploadurl = [Nsurl fileurlwithpath:[[appdocumentpath stringbyappendingpathcomponent:[self dateString]] Stringbyappendingstring:@". mp4"]]; //Compress Movie First[self convertvideotolowquailtywithinputurl:url outputurl:uploadurl]; [Self Dismissviewcontrolleranimated:yes completion:^{ }]; }
iOS video capture compress upload and play