使用AVAssetExportSession导出大文件需要更多时间(大约800 MB)

时间:2017-07-20 13:09:25

标签: ios swift3 phasset avassetexportsession avasset

您好我正在尝试使用AVAssetExportSession导出大小接近800 MB的视频文件,这需要将近2-3分钟才能完成此过程。我已经尝试将导出会话预设设置为AVAssetExportPresetPassthrough,AVAssetExportPresetHighestQuality以及其他用于试用,但根据需要不适合我。 这有什么办法吗?

有关详细信息,我已经提供了以下代码:

let defaultRep = PHImageManager.default()
let str = "\(UIDevice.current.identifierForVendor!.uuidString).mov"
url =  url.appendingPathComponent(str)
defaultRep.requestExportSession(forVideo: self.phasset, options: PHVideoRequestOptions?.none, exportPreset: AVAssetExportPresetPassthrough, resultHandler: { (exportSession, info) -> Void in
        guard let exportSession = exportSession
          else {
            if let error = info?[PHImageErrorKey] as? NSError {
            } else {
            }
            return
        }
        exportSession.outputFileType = AVFileTypeQuickTimeMovie
        exportSession.shouldOptimizeForNetworkUse = true
        let str = "\(UIDevice.current.identifierForVendor!.uuidString).mov"
        url =  url.appendingPathComponent(str)
        self.removeFile(url)
        exportSession.outputURL = url as URL



        exportSession.exportAsynchronously(completionHandler: { () -> Void in
          switch exportSession.status{
          case .completed :
            print("Complete")
            print(exportSession.outputURL)
            print(self.phasset.pixelWidth)
            print(self.phasset.pixelHeight)
            self.mediaType = SBMediaType.SBMediaTypeVideo
            self.videoUrl = exportSession.outputURL
            withCompletionhandler(self)
            break
          case .cancelled:
            print("cancelled")
            if let error = exportSession.error {
              print(error)
            }
            break
          case .exporting:
            print("Exporting")
            if let error = exportSession.error {
              print(error)
            }
            break
          case .failed:
            print("Exporting")
            if let error = exportSession.error {
              print(error)
            }
            break
          case .waiting:
            print("Waiting")
            if let error = exportSession.error {
              print(error)
            }
            break
          default :
            break
          }
        })
      })

0 个答案:

没有答案