0

I have a video conferencing app and we are setting up AVAudioSession to videoChat so that we can get echo cancellation.

let options: AVAudioSession.CategoryOptions = [.mixWithOthers , .defaultToSpeaker, .allowBluetooth]
try session.setCategory(.playAndRecord, mode: .videoChat, options: options)

I also want to do local recording of audio samples using AVAssetWriter API. Setup of AssertWriter is as follows:

let audioAssetWriter = try AVAssetWriter(outputURL: fileURL, fileType: .m4a)
     
let settings: [String: Any] = [
AVFormatIDKey: Int(kAudioFormatMPEG4AAC),
AVSampleRateKey: Int(audioParameters.samplingRate),
AVEncoderBitRateKey: Int(audioParameters.bitrate),
AVNumberOfChannelsKey: Int(audioParameters.channels),
AVEncoderAudioQualityKey: AVAudioQuality.max.rawValue
]
       
let assetWriterAudioInput = AVAssetWriterInput(mediaType: .audio, outputSettings: settings)
assetWriterAudioInput.expectsMediaDataInRealTime = true
audioAssetWriter.add(assetWriterAudioInput)

I am seeing that on the iPhone 14 Pro,

assetWriterAudioInput.append()

is failing. Everything works fine on iPhone 13 and older devices.

Is anyone else seeing this issue on the iPhone 14 Pro.

  • Are you sure the `AVAssetWriterInput` `outputSettings` match the sample buffers you're appending? `AVAssetWriter.status` and `AVAssetWriter.error` should tell you something when append fails. What do they say? – Rhythmic Fistman Dec 01 '22 at 07:46
  • I also tried calling `AVCaptureAudioDataOutput.recommendedAudioSettingsForAssetWriter(writingTo: .m4a)` to get recommended settings and then feed those to the `AVAssetWriterInput` constructor - but that did not help – Adeel Abbas Dec 01 '22 at 19:37
  • AVAssetWriter.status is .failed AVAssetWriter.error code is -11800 (operation could not be completed) – Adeel Abbas Dec 01 '22 at 19:38
  • Was there any other text in that log? `-11800 = AVErrorUnknown` is the "outer" error. It usually wraps an "inner" error. – Rhythmic Fistman Dec 02 '22 at 17:22

0 Answers0