1

谁能帮我解决这个问题,在压缩视频时出错,例如:

NSLocalizedFailureReason=发生未知错误 (-12780)

   let destinationPath =  NSURL(string: VideoFilePath)!     
   let sourceAsset = AVURLAsset(url: inputURL as URL, options: nil)

    let assetExport: AVAssetExportSession = AVAssetExportSession(asset: sourceAsset, presetName: AVAssetExportPresetLowQuality)!
    assetExport.outputFileType = AVFileTypeQuickTimeMovie
    assetExport.outputURL = savePathUrl as URL
    assetExport.exportAsynchronously { () -> Void in

        switch assetExport.status {
        case AVAssetExportSessionStatus.completed:
            DispatchQueue.main.async {
                do {
                    let videoData = try NSData(contentsOf: savePathUrl as URL, options: NSData.ReadingOptions())
                   // self.sendVideoMessage(sender: self.appDelegate.xmppStream!, vidoeData: videoData as NSData, senderJID: self.rosterInfo.jid!,duration: assetExport.asset.duration)

                } catch {
                    print(error)
                }
            }
        case  AVAssetExportSessionStatus.failed:
            print("failed \(assetExport.error)")
        case AVAssetExportSessionStatus.cancelled:
            print("cancelled \(assetExport.error)")
        default:
            print("Task Done")
        }
    }
4

1 回答 1

2

使用这种方式:

代替

let destinationPath =  NSURL(string: VideoFilePath)!     

let destinationPath =  NSURL(fileURLPath: VideoFilePath)!     
于 2017-01-31T09:19:30.797 回答