Take the 2-minute tour ×

I have a 22kHz wave file and want a 22kHz m4a file. AVAssetExportSession with the preset AVAssetExportPresetAppleM4A automatically converts my wav to 44kHZ. I've tried different presets and nil to create the ExportSession, but without success.

Is there a way to set custom export properties of an AVAssetExportSession or do I need a completely different approach like the one stated in How to convert WAV file to M4A??

here is the code I have so far, which works great if you want a 44kHz file:

AVURLAsset *wavAsset = [AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:wavPath] options:optionsDict];

AVMutableComposition *mutableComposition = [AVMutableComposition composition];
[mutableComposition insertTimeRange:CMTimeRangeMake(kCMTimeZero, wavAsset.duration)
  ofAsset:wavAsset atTime:kCMTimeZero error:&error];

AVAssetExportSession *exportSession = [[AVAssetExportSession alloc]
  initWithAsset:[mutableComposition copy] presetName:AVAssetExportPresetAppleM4A];
exportSession.outputURL = [NSURL fileURLWithPath:m4aPath];
exportSession.outputFileType = AVFileTypeAppleM4A;

[exportSession exportAsynchronouslyWithCompletionHandler:^{
  switch (exportSession.status) {
    case AVAssetExportSessionStatusCompleted: {
      [exportSession release];
    case AVAssetExportSessionStatusFailed: {
      NSLog(@"There was an error while exporting the file: %@", exportSession.error);
    // ... handle some other cases...
    default: {

Would be great if I just missed something.

Thanks in advance, Dom

share|improve this question

1 Answer 1

up vote 0 down vote accepted

I've had some luck with the TPAACAudioConverter available here. It uses the ExtendedAudioFile API in the AudioToolbox Framework.

share|improve this answer

Your Answer


