AVAssetExportSession not working on devices, but working on simulator (AVFoundationErrorDomain Code = -11800, Unknown Error code -12780)

后端 未结 2 388
长发绾君心
长发绾君心 2021-01-29 04:39

EDIT: To make things easier to anyone interested in checking out this problem, I added a demo project to this github repository.

Issue<

相关标签:
2条回答
  • 2021-01-29 04:41

    You must use, default method: appendingPathComponent()

    0 讨论(0)
  • 2021-01-29 05:03

    The problem is that you're appending string to another string resulting in wrong path to the file like file:///var/mobile/Containers/Data/Application/<stripped>/DocumentsFinalVideo.mov

    You should use appendingPathComponent() instead:

    func createPath() -> URL {
        let paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)
        let documentDirectory = URL(fileURLWithPath: paths.first!)
        let url = documentDirectory.appendingPathComponent("FinalVideo.mov")
    
        if FileManager.default.fileExists(atPath: url.path) {
            try? FileManager.default.removeItem(at: url)
        }
    
        return url
    }
    
    0 讨论(0)
提交回复
热议问题