'iOS Objective C Opus audio stream kAudioFormatOpus -- specification / conversion query

I'm working on a React Native voice app wanting to record straight to an Opus stream.

On the iOS side at device level, I'm working in Objective C and I'm using an AVAudioSession recorder with formatID set to kAudioFormatOpus. The recorder captures audio data in the specified format and passes packets for upstreaming to the React Native app.

This is all working well and emitting a stream of audio data when I run my code on an iOS Simulator or real device.

My problem is when I receive the audio stream in the backend, I find I'm unable to reliably decode the Opus stream using ffmpeg. (I wish to decode to PCM.)

Whilst I could post up specific code to show what I'm doing in more detail, my question at this stage is more generic in nature:

Is anyone familiar with the format of Opus audio stream that is generated by iOS AudioSession recorder under audio format kAudioFormatOpus ? Is anyone able to suggest proven conversion techniques? (e.g. some ffmpeg commands), or else hook me up with some links to format specs so I can figure out what is going on here ?

The Apple Developer documentation contains zero useful information: https://developer.apple.com/documentation/coreaudiotypes/1572096-audio_data_format_identifiers/kaudioformatopus?changes=la__2&language=objc

I have looked all over the internet, but I'm unable to find any useful spec info that corresponds to the stream that AVAudioSession recorder is outputting. I have seen a few posts which say Apple have not fully complied with the Opus spec, but I don't know enough about the proper structure of Opus to ascertain this for myself.

Any help would be very much appreciated.

Thanks all



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source