1

I'm working on an image to video slideShow project.

I have several transition effect on my project. I'm using the AVFoundation library but the transition is not working on iOS 14. When I call exportAsynchronously(completionHandler:{}} it throws error(Thread 26: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)). I can't understand the problem with my code. Is it an iOS14 version problem or something else

Below is the code I'm using

let layercomposition = AVMutableVideoComposition()
        layercomposition.frameDuration = CMTimeMake(value: 1, timescale: 30)
        layercomposition.renderSize = size
        layercomposition.animationTool = AVVideoCompositionCoreAnimationTool(postProcessingAsVideoLayer: videolayer, in: parentlayer)
        let instruction = AVMutableVideoCompositionInstruction()
        instruction.timeRange = CMTimeRangeMake(start: CMTime.zero, duration: composition.duration)
        let videotrack = composition.tracks(withMediaType: AVMediaType.video)[0] as AVAssetTrack
        let layerinstruction = AVMutableVideoCompositionLayerInstruction(assetTrack: videotrack)
        instruction.layerInstructions = [layerinstruction]
        layercomposition.instructions = [instruction]
        
        var today: String = String()
        today = getCurrentTimeAsString()
        
        
        
        videoURLFromSelectedPhotos = NSURL(fileURLWithPath: NSHomeDirectory() + "/Documents/PhotoSlide/PicSlide_\(today).mp4")
        removeFileAtURLIfExists(url: videoURLFromSelectedPhotos)
        
        guard let assetExport = AVAssetExportSession(asset: composition, presetName:AVAssetExportPresetHighestQuality) else {return}
        assetExport.videoComposition = layercomposition
        assetExport.outputFileType = AVFileType.mp4
        assetExport.outputURL = videoURLFromSelectedPhotos as URL
        
        
        
     
        // MARK:  exportAsynchronously crash on iso 14
        
        assetExport.exportAsynchronously(completionHandler: {})

0 Answers0