Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Best way to compress the Video.</p> <p>Here is the code.</p> <pre><code> -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ NSString *tempFilePath = [[info objectForKey:UIImagePickerControllerMediaURL] path]; NSData *data = [NSData dataWithContentsOfURL:videoURL]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSDate *now = [NSDate dateWithTimeIntervalSinceNow:0]; NSString *caldate = [NSString stringWithFormat:@"%@.mov",[now description]]; caldate = [caldate stringByReplacingOccurrencesOfString:@" " withString:@""]; NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path = [NSString stringWithFormat:@"%@/%@", documentsDirectory,caldate]; NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType]; NSURL *selectedVideoUrl; if (CFStringCompare ((__bridge CFStringRef) mediaType, kUTTypeMovie, 0) == kCFCompareEqualTo) { tempFilePath = [[info objectForKey:UIImagePickerControllerMediaURL] path]; selectedVideoUrl = [info objectForKey:UIImagePickerControllerMediaURL]; } NSLog(@"old move %@",path); NSURL *url = [NSURL fileURLWithPath:tempFilePath]; [data writeToFile:path atomically:YES]; //Delete the original asset NSArray *paths1 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory1 = [paths1 objectAtIndex:0]; NSString *path1 = [NSString stringWithFormat:@"%@/%@", documentsDirectory1,caldate]; NSURL *url1 = [NSURL fileURLWithPath:path1]; NSLog(@"new move %@",path); [self convertVideoToLowQuailtyWithInputURL:url outputURL:url1 handler:Nil]; [picker dismissModalViewControllerAnimated: YES]; </code></pre> <p>}</p> <pre><code> -(void)convertVideoToLowQuailtyWithInputURL:(NSURL*)inputURL outputURL:(NSURL*)outputURL handler:(void (^)(AVAssetExportSession*))handler{ AVURLAsset *asset = [AVURLAsset URLAssetWithURL:inputURL options:nil]; AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetMediumQuality]; exportSession.outputURL = outputURL; if ([[UIApplication sharedApplication]canOpenURL:inputURL]){ NSLog(@"open"); } exportSession.outputFileType = AVFileTypeQuickTimeMovie; NSLog(@"errrsfseSession %@", exportSession.error); [exportSession exportAsynchronouslyWithCompletionHandler:^(void) { if(exportSession.status != AVAssetExportSessionStatusCompleted){ NSLog(@"exportSession %@", exportSession.error); } if (exportSession.status == AVAssetExportSessionStatusCompleted) { NSLog(@"doneszdfsadj"); } }]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload