rFlex / SCRecorder

iOS camera engine with Vine-like tap to record, animatable filters, slow motion, segments editing
Apache License 2.0
3.06k stars 583 forks source link

Trying to export an imported video with filter/overlay. #283

Closed viktorgardart closed 8 years ago

viktorgardart commented 8 years ago

So im trying to export a video that's imported via the photo library and applying a filter onto it. My code looks like below

let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as NSString
let formatter = NSDateFormatter()
formatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"
let date = NSDate()
let outputPath = "\(documentsPath)/\(formatter.stringFromDate(date)).mp4"
let outputURL = NSURL(fileURLWithPath: outputPath)

let asset = AVAsset(URL: self.video.url)
let exportSession = SCAssetExportSession()
exportSession.inputAsset = asset
exportSession.outputUrl = outputURL
exportSession.outputFileType = AVFileTypeMPEG4
exportSession.videoConfiguration.filter = SCFilter(CIFilterName: "CIPhotoEffectInstant")
exportSession.videoConfiguration.preset = SCPresetHighestQuality
exportSession.audioConfiguration.preset = SCPresetMediumQuality
exportSession.exportAsynchronouslyWithCompletionHandler {
  if exportSession.error == nil {
    self.video.url.saveToCameraRollWithCompletion({ (string, error) -> Void in
      print(string)
    })
  }else {
    print(exportSession.error?.localizedDescription)
  }
}

So the saving works. It's just not applying the filter that i've specified. Bug, feature or am i doing it wrong?

Edit: I also tried to export with an overlay, didn't work either.

viktorgardart commented 8 years ago

I feel stupid now.

As you can see on this line:

self.video.url.saveToCameraRollWithCompletion({ (string, error) -> Void in

I am saving the input source instead of the exported source..

JayBone16 commented 6 years ago

You stated "self.video.url.saveToCameraRollWithCompletion({ (string, error) -> Void in". What did you connect to the word video? recordSession? exportSession?

JayBone16 commented 6 years ago

Could you please upload code of the working copy? Thanks