3

I'm newbie in iPhone programming and i need some help. I'm writing an application which should record audio and video data simultaneously but to different targets because i need to process audio data separately.

So i tried several ways of implementing this and decided to do it with AVFoundation.

The problem is i really don't know how to save output audio data to a file by my own.. What format and other properties should i use for it..

I set up audio input for AVCaptureSession and receive audio data in the following way:

- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
       fromConnection:(AVCaptureConnection *)connection
{
    AudioBufferList audioBufferList;
    CMBlockBufferRef blockBuffer;

    // Here i get AudioBufferList to save audio data
    CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(
                                                            sampleBuffer, 
                                                            NULL, 
                                                            &audioBufferList, 
                                                            sizeof(audioBufferList), 
                                                            NULL, 
                                                            NULL, 
                                                            0, 
                                                            &blockBuffer);

    // Here should be saving logic
}

Could you please to give me a hint of how it can be implemented and in what way should i look?

Thanx in advance, Jan.

Jan Lobau
  • 221
  • 6
  • 13
  • you want to compress and write to file using AVAssetWriter.. – Daniel Sep 14 '11 at 15:46
  • Thanx a lot! i finally succeeded with this task. This post also helped me: http://stackoverflow.com/questions/4149963/this-code-to-write-videoaudio-through-avassetwriter-and-avassetwriterinputs-is-n/4437047#4437047 – Jan Lobau Sep 15 '11 at 13:44

0 Answers0