iosaudioparse-platformm4aaiff

Trouble storing Audio on Parse in an m4a format


I am trying to record audio using the amazing audio engine and then upload it to Parse.

There is a great question on stackoverflow which seems to deal with this here but I am having problems with the m4a formatting side of things meaning this answer doesn't help me.

This is how I record audio:

self.recorder = [[AERecorder alloc] initWithAudioController:_audioController];

NSArray * documentsFolders = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString * path = [documentsFolders[0] stringByAppendingPathComponent:@"Recording.aiff"];

And then how I save it to Parse:

NSArray * documentsFolders = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString * path = [documentsFolders[0] stringByAppendingPathComponent:@"Recording.aiff"];

NSData * audioData = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath:path]];

PFObject * testObject = [PFObject objectWithClassName:@"TestObject"];

PFFile * audioFile = [PFFile fileWithName:@"audio.aiff" data:audioData];

testObject[@"audioFile"] = audioFile;
[testObject saveInBackground];

This all works fine and the audio is uploaded and saved correctly.

The problem is that I am saving the audio in an aiff format, this means it takes longer to stream and upload as it is a larger file. I really want to save the audio in an m4a format as speed is more of an issue than quality.

I find though when I change .aiff to .m4a suddenly it doesn't work.

Is there something I am doing wrong or overlooking? I feel that this should be a quick an easy change so any advise would be greatly appreciated.


Solution

  • Can you try telling the AERecorder to use M4A format and see if that helps (in addition to changing the filenames.)

    [self.recorder prepareRecordingToFileAtPath:path fileType:kAudioFileM4AType error:nil];
    

    Or setting that fileType in beginRecording.

    http://theamazingaudioengine.com/doc/interface_a_e_recorder.html#pub-methods