通过EXC_BAD_INSTRUCTION进行AVAssetExportSession

问题描述

我正在处理图像到视频slideShow项目。

我对我的项目有几个过渡效果。 我正在使用AVFoundation库,但该转换在iOS 14上不起作用。 当我呼叫 exportAsynchronously(completionHandler:{}} 时,它会引发错误 Thread 26: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP,subcode=0x0) )。 我无法理解我的代码中的问题。是iOS14版本问题还是其他问题

下面是我正在使用的代码

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: {})

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...