Objective-C Tips & Trick - Prioregroup.com
[Objective-C] Convert video to MP4 from a URL
       
back

#import <AssetsLibrary/AssetsLibrary.h>
#import <AVFoundation/AVFoundation.h>

// temp filename
NSString *fname = [NSString stringWithFormat:@"%.f.mp4", [NSDate timeIntervalSinceReferenceDate]];
NSURL *videoURL = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:fname]];

// convert to MP4
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil];
AVAssetExportSession *session = [AVAssetExportSession exportSessionWithAsset:asset presetName:AVAssetExportPresetPassthrough];
session.outputFileType = AVFileTypeMPEG4;
session.outputURL = videoURL;
[session exportAsynchronouslyWithCompletionHandler:^{
	NSLog("Video converted!");
}];






Copyright © 1996-2018 Centro Studi Informatica di Danilo Priore. All rights reserved. P.I.10149810581.
prioregroup.com