Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I append to a recorded MPEG4 AAC file?
    text
    copied!<p>I'm recording audio on an iPhone, using an <code>AVAudioRecorder</code> with the following settings:</p> <pre><code>NSMutableDictionary *recordSettings = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt: kAudioFormatMPEG4AAC], AVFormatIDKey, [NSNumber numberWithFloat:44100.0], AVSampleRateKey, [NSNumber numberWithInt:1], AVNumberOfChannelsKey, [NSNumber numberWithInt:12800], AVEncoderBitRateKey, [NSNumber numberWithInt:16], AVLinearPCMBitDepthKey, [NSNumber numberWithInt: AVAudioQualityHigh], AVEncoderAudioQualityKey, nil]; </code></pre> <p>(I can be flexible on most of these settings, but I have to use MPEG4 AAC.)</p> <p>I save the audio to a file.</p> <p>The user needs to be able to come back at a later date and continue recording to the same file. There doesn't seem to be an option to do this directly with <code>AVAudioRecorder</code>, so instead I'm recording to a new file and concatenating them.</p> <p>At the moment I'm appending the files using an <code>AVMutableComposition</code> and an <code>AVMutableCompositionTrack</code> as <a href="https://stackoverflow.com/questions/4191569/how-to-append-two-audio-files">here</a>, but it's really slow for longer recordings so this isn't really feasible.</p> <p>I'm thinking it would be much quicker if I could strip the header from the second file, append the audio data to the first file, then alter the header of the combined file to reflect the new duration. As I know both files were created with exactly the same settings, I figure the other details in the headers should be identical.</p> <p>Unfortunately I can't find any information about what format the headers are in, or if it's possible to combine files in this way.</p> <p>So my questions are:</p> <ul> <li>What is the format of the MPEG-4 AAC file header, when created on an iPhone?</li> <li>Can I combine two audio files by messing with the headers like this?</li> <li>Is there a better way of appending two MPEG-4 AAC audio files almost instantaneously?</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload