1

I'm using speak here code for audio recording with audio format kAudioFormatMPEG4AAC. How can i change bit rate to 96K, 128K or 320K?

Regards, John

John
  • 49
  • 3
  • Duplicate: http://stackoverflow.com/questions/4655277/what-is-audiostreambasicdescription-for-m4a-file-format http://developer.apple.com/library/mac/#documentation/MusicAudio/Reference/CAFSpec/CAF_spec/CAF_spec.html#//apple_ref/doc/uid/TP40001862-CH210-TPXREF101 has additional details. – chilitechno.com Apr 26 '11 at 19:57

2 Answers2

3

I'm not sure if you can do this directly using AudioQueue by setting a parameter. However, I think the following approach will work:

  • Setup your AudioQueue to record to linear PCM
  • Setup an ExtAudioFile with a client data format matching the AudioQueue and a file data format of AAC
  • Set the desired AAC bitrate by getting the AudioConverter associated with the ExtAudioFile (kExtAudioFileProperty_AudioConverter) and set the converter's bitrate (kAudioConverterEncodeBitRate).

I haven't tried this on iOS, but if the AAC encoder is using a hardware codec I doubt you will be able to set the bitrate. AudioFormat.h gives some methods to determine which codecs are hardware vs. software and ways to request one implementation vs. another.

sbooth
  • 16,646
  • 2
  • 55
  • 81
  • sbooth, can you please comment on my question? I see you have experience with this Core Audio. http://stackoverflow.com/questions/41638475/how-to-set-bitrate-correctly-for-aac-encoding-osx – mbaros Jan 13 '17 at 17:30
0

The fact is, AudioQueue is using the same backend as AudioConverter, although there is no key for bitRate in AudioQueueProperty enom, you can still borrow them from converter. Get the bit rate like this:

AudioQueueGetProperty(mQueue, kAudioConverterEncodeBitRate, &bitRate, &propertySize);

and set it like this:

AudioQueueSetProperty(mQueue, kAudioConverterEncodeBitRate, &bitRate, propertySize);
Farhad Malekpour
  • 1,314
  • 13
  • 16