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

Transform only considered when filter is applied #311

Closed Bragegs closed 8 years ago

Bragegs commented 8 years ago

Hi! Mission: Rotating an AVAsset and export it.

Issue: Occurs when i export the video. The rotation/transform seems to be taken in to consideration only when a filter from the SCSwipeableFilter is applied. "emptyFilter" doesnt change the preffered transform.

I set the the rotation transform both to AVMutableCompositionTrack, and AVMutableVideoCompositionLayerInstruction.

Reproduce:

// Exporting code
            self.mutableComposition.tracksWithMediaType(AVMediaTypeVideo)[0].preferredTransform = self.storedPrefferedTransform
            let playerItem = AVPlayerItem(asset: self.mutableComposition)
            exportSession = SCAssetExportSession(asset: playerItem.asset )
            if let currentFilter = self.videoDisplay.selectedFilter?.copy() as? SCFilter{
                    exportSession.videoConfiguration.filter = currentFilter
            }
            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)
            exportSession.videoConfiguration.preset = SCPresetHighestQuality
            exportSession.audioConfiguration.preset = SCPresetHighestQuality
            exportSession.videoConfiguration.affineTransform = self.storedPrefferedTransform
            exportSession.videoConfiguration.keepInputAffineTransform = false
            exportSession.videoConfiguration.maxFrameRate = 35
            exportSession.outputFileType = AVFileTypeMPEG4
            exportSession.outputUrl = outputURL
            exportSession.delegate = self
            exportSession.contextType = .Auto
            exportSession.exportAsynchronouslyWithCompletionHandler({