【问题标题】:Merge two audio file failed合并两个音频文件失败
【发布时间】:2017-08-19 17:23:25
【问题描述】:

Domain=AVFoundationErrorDomain Code=-11838 \"Operation Stopped\" UserInfo={NSLocalizedDescription=Operation Stopped, NSLocalizedFailureReason=此媒体不支持该操作。})")

{来源:caf lpcm,目的地:aiff or wav or 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。我需要 caf 或 wav 或 aiff 文件,帮助...

【问题讨论】:

    标签: ios swift avfoundation avassetexportsession


    【解决方案1】:

    替换这一行:

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

    与:

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

    希望它会起作用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多