priore

Convert video to MP4 from a URL

Apr 23rd, 2015
949
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #import <AssetsLibrary/AssetsLibrary.h>
  2. #import <AVFoundation/AVFoundation.h>
  3.  
  4. // temp filename
  5. NSString *fname = [NSString stringWithFormat:@"%.f.mp4", [NSDate timeIntervalSinceReferenceDate]];
  6. NSURL *videoURL = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:fname]];
  7.  
  8. // convert to MP4
  9. AVURLAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil];
  10. AVAssetExportSession *session = [AVAssetExportSession exportSessionWithAsset:asset presetName:AVAssetExportPresetPassthrough];
  11. session.outputFileType = AVFileTypeMPEG4;
  12. session.outputURL = videoURL;
  13. [session exportAsynchronouslyWithCompletionHandler:^{
  14.     NSLog("Video converted!");
  15. }];
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×