Full Quality For Video Upload
-
Im picking a video from UIImagePicker, the video is then being uploaded to my server. I want the quality of the video to remain the same. As of right now the video has a bit less quality compared to the one i took directly off my phone, and it is a smaller resolution. here is my code: -(IBAction)video:(id)sender{ UIImagePickerController *picker = [[UIImagePickerController alloc] init]; picker.delegate = self; picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; picker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil]; picker.allowsEditing = YES; picker.wantsFullScreenLayout = YES; picker.videoQuality = UIImagePickerControllerQualityTypeHigh; [self presentModalViewController:picker animated:YES]; } - (NSData *)generatePostDataForData:(NSData *)uploadData { // Generate the post header: NSString *post = [NSString stringWithCString:"--AaB03x\r\nContent-Disposition: form-data; name=\"upload[file]\"; filename=\"somefile\"\r\nContent-Type: application/octet-stream\r\nContent-Transfer-Encoding: binary\r\n\r\n" encoding:NSASCIIStringEncoding]; // Get the post header int ASCII format: NSData *postHeaderData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; // Generate the mutable data variable: NSMutableData *postData = [[NSMutableData alloc] initWithLength:[postHeaderData length] ]; [postData setData:postHeaderData]; // Add the image: [postData appendData: uploadData]; // Add the closing boundry: [postData appendData: [@"\r\n--AaB03x--" dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]]; // Return the post data: return postData; } - (void)post:(NSData *)fileData { NSData *videoData = fileData; NSString *urlString = @"http://www.site.com/scripts/upload.php"; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request setURL:[NSURL URLWithString:urlString]]; [request setHTTPMethod:@"POST"]; NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"]; NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary]; [request addValue:contentType forHTTPHeaderField:@"Content-Type"]; NSMutableData *body = [NSMutableData data]; [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"userfile\"; filename=\".mov\"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[NSData dataWithData:videoData]]; [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [request setHTTPBody:body]; NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding]; NSLog(@"%@", returnString); } - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ [self dismissModalViewControllerAnimated:YES]; //assign the mediatype to a string NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType]; //check the media type string so we can determine if its a video NSLog(@"got a movie"); NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL]; NSData *webData = [NSData dataWithContentsOfURL:videoURL]; [self post:webData]; } setting the pickers quality to high i thought would do it, i guess not. I have the option to export in 720p, but i want iphone 4s's to upload in full 1080p. Any help would be great. Thanks :D
-
Answer:
You can't skip the annoying compression step, UIImagePicker insists on doing it. You can get at the high quality video by using the UIImagePickerControllerReferenceURL key, however the long compression step is a deal breaker for me. So go log a bug, then check out this excellent https://github.com/guicocoa/photopicker-ios.
Jacob at Stack Overflow Visit the source
Related Q & A:
- How do you get the option for high quality on your youtube video?Best solution by Yahoo! Answers
- What is a good video quality to convert to?Best solution by Super User
- How to improve my code to make the video quality better?Best solution by Stack Overflow
- Why won't my video upload to YouTube?Best solution by Yahoo! Answers
- Is it legal to upload youtube video to other video websites?Best solution by answers.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.