Advertisement
Guest User

Untitled

a guest
Jul 12th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. class func compressVideo(_ inputURL: URL, outputURL: URL, handler:@escaping (_ session: AVAssetExportSession)-> Void){
  2. let urlAsset = AVURLAsset(url: inputURL, options: nil)
  3.  
  4. let exportSession = AVAssetExportSession(asset: urlAsset, presetName: AVAssetExportPresetMediumQuality)
  5.  
  6. exportSession!.outputURL = outputURL
  7.  
  8. exportSession!.outputFileType = AVFileType.mp4
  9.  
  10. exportSession!.shouldOptimizeForNetworkUse = true
  11.  
  12. exportSession!.exportAsynchronously { () -> Void in
  13. handler(exportSession!)
  14. }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement