2017-03-27 106 views
2

域= AVFoundationErrorDomain代码= -11838 \ “停止运行\” 的UserInfo = {NSLocalizedDescription =停止运行,NSLocalizedFailureReason =不支持此操作此媒体。})“)合并两个音频文件失败

{起源:CAF LPCM,目的地:AIFF或WAV或CAF}

这里是代码:

 let composition = AVMutableComposition() 
     self.prepareToCombineMedia(composition) 

     let exportSession = AVAssetExportSession(asset: composition, presetName: AVAssetExportPresetPassthrough)! 

     let tmpFilePath = FileUtils.tempFile(ext: "caf") 
     exportSession.outputURL = NSURL.fileURL(withPath: tmpFilePath) 
     exportSession.outputFileType = AVFileTypeCoreAudioFormat 
     exportSession.exportAsynchronously { 
      if exportSession.status == .completed { 
       print("completed") 
       print(tmpFilePath) 
       subscriber.onCompleted() 
      } else { 
       subscriber.onError(LeafError.runtime(message: exportSession.error.debugDescription)) 
       FileUtils.rm(tmpFilePath) 
      } 
     } 

它只能被合并到M4A或MOV我需要咖啡馆或WAV或AIFF文件,帮助.. 。

回答

1

替换此行:

let exportSession = AVAssetExportSession(asset: composition, presetName: AVAssetExportPresetPassthrough)! 

有:

let exportSession = AVAssetExportSession(asset: composition, presetName: AVAssetExportPresetAppleM4A) 

希望它会工作