ios - Video file compression in swift -


this question has answer here:

i m recording video , converting base64 string send server.but uploading of video taking lot of time. there compression library can used swift. tried bridging ffmpeg creating lot of issue of missing files. avurlasset not working me. suggestions on how compress audio , video files.

func imagepickercontrollerdidcancel(picker: uiimagepickercontroller) {         self.imagepickercontroller.dismissviewcontrolleranimated(true, completion: nil)     }      func imagepickercontroller(picker: uiimagepickercontroller, didfinishpickingmediawithinfo info: [string : anyobject]) {         let mediatype = info[uiimagepickercontrollermediatype] as! nsstring         self.imagepickercontroller.dismissviewcontrolleranimated(true) {             // 3             if mediatype == kuttypemovie {                  guard let path = (info[uiimagepickercontrollermediaurl] as! nsurl).path else { return }                  if uivideoatpathiscompatiblewithsavedphotosalbum(path) {                     uisavevideoatpathtosavedphotosalbum(path,    self, #selector(galleryview.video(_:didfinishsavingwitherror:contextinfo:)), nil)                  }             }else{                 //image                 let selectedimage = info[uiimagepickercontrolleroriginalimage] as! uiimage                 let imagedata:nsdata = uiimagejpegrepresentation(selectedimage,0.5)!                 var strbase64:string = imagedata.base64encodedstringwithoptions(.encodingendlinewithlinefeed)                 strbase64 = strbase64.stringbyreplacingoccurrencesofstring("+", withstring: "%2b")                 self.uploadgallerydatainserver("1", ext: "jpeg", content: strbase64)             }         }     }      func video(videopath: nsstring, didfinishsavingwitherror error: nserror?, contextinfo info: anyobject) {         if let _ = error {         }else{            print("videopath = \(videopath)")             let data = nsdata(contentsoffile: videopath string)              var strbase64:string = nsdata(contentsoffile: videopath string)!.base64encodedstringwithoptions(.encodingendlinewithlinefeed)             strbase64 = strbase64.stringbyreplacingoccurrencesofstring("+", withstring: "%2b")               self.uploadgallerydatainserver("2", ext: ".mp4", content: strbase64)         }     } 


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -