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

use SCRecorder to add filter to existng video doesnot work ok #294

Open github2016a opened 8 years ago

github2016a commented 8 years ago

hello guys,i am using the SCRecorder as a function project,i have a video file recorded by iphone in portrait mode(MOV format),and i am using the following code to add filter to it, but the output file doesnot seem ok, it is in landscape mode , and been cropped.

    let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as NSString
    let inputUrl = NSURL(fileURLWithPath: "\(documentsPath)/aa.MOV")
    let outputUrl = NSURL(fileURLWithPath: "\(documentsPath)/bb.mp4")
    let currentFilter = SCFilter(CIFilterName: "CIPhotoEffectChrome")
    let exportSession = SCAssetExportSession.init(asset: AVAsset.init(URL:inputUrl))
    exportSession.videoConfiguration.filter = currentFilter
    exportSession.videoConfiguration.preset = SCPresetHighestQuality
    exportSession.audioConfiguration.preset = SCPresetHighestQuality
    exportSession.videoConfiguration.maxFrameRate = 35
    exportSession.outputUrl = self.outputUrl
    exportSession.outputFileType = AVFileTypeMPEG4
    exportSession.contextType = SCContextType.Auto

    exportSession.exportAsynchronouslyWithCompletionHandler { () -> Void in
    }
EthanSchatzline commented 8 years ago

Any update on this? I am getting the same thing. :/

renjithn commented 8 years ago

This could be problem with the new method- + (AVMutableVideoComposition *)videoCompositionWithAsset:(AVAsset *)asset applyingCIFiltersWithHandler:(void (^)(AVAsynchronousCIImageFilteringRequest *request))applier

Doesn't seem to respect the video transform during export. You can disable this by explicitly setting exportSession.translatesFilterIntoComposition = NO