Search code examples
iosaudiorecord

Programmatically compress recorded Audio


When I record Audio in my iPhone application, the file size is huge. How can I compress audio?


Solution

  • I've not done this, but it looks pretty straightforward.

    When you create your AVAudioRecorder, you can specify the destination URL, format and nitrate. If you choose a compressed format and appropriate bitrate, the data will be automatically compressed for you. If you choose AAC, it should also be compressed in hardware.

    You want to use AVAudioRecorder's initWithURL:settings:error: The constants you need are in General Audio Format Settings. I'd guess your best bet would be kAudioFormatMPEG4AAC.

    You only want to compress audio using an audio codec, any other way is inefficient and will produce poor audio.