当我使用 avassetexportsession 时,有时会起作用,但有时会失败,并且出现以下错误。我查看了在线和苹果文档,但找不到有关此错误的任何内容。
错误:
Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could
not be completed" UserInfo={NSUnderlyingError=0x14dcf3bf0
{Error Domain=NSOSStatusErrorDomain Code=-12842 "(null)"},
NSLocalizedFailureReason=An unknown error occurred (-12842)
Run Code Online (Sandbox Code Playgroud)
代码:
let url = NSURL.fileURLWithPath(savedFileTest)
EditSongViewController.url.urlComplete = url
let exporter = AVAssetExportSession(asset: mixedFile, presetName: AVAssetExportPresetMediumQuality)
exporter!.audioMix = audioMixer
exporter!.outputURL = url
exporter!.outputFileType = AVFileTypeMPEG4
exporter!.exportAsynchronouslyWithCompletionHandler( {
// this handler gets called in a background thread!
switch exporter!.status {
case AVAssetExportSessionStatus.Failed:
self.indicator.stopAnimation(false, completion: nil)
//println("failed url=\(exporter.outputURL), error=\(exporter.error)")
return;
case AVAssetExportSessionStatus.Cancelled:
self.indicator.stopAnimation(false, completion: nil)
return;
default:
self.indicator.stopAnimation(false, completion: nil) …Run Code Online (Sandbox Code Playgroud)