• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Convert AudioBufferList to CMSampleBuffer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Convert AudioBufferList to CMSampleBuffer


  • Subject: Convert AudioBufferList to CMSampleBuffer
  • From: patrick machielse <email@hidden>
  • Date: Tue, 08 May 2012 22:40:36 +0200

On iOS I need to write data coming in from an AUGraph/Unit to file. To this end I need to convert sample data contained in an AudioBufferList to a CMSampleBuffer in order to append it to a AVAssetWriterInput.

It seems there isn't a lot of info available on how to do that exactly (and successfully). I've managed to come up with the following code, which uses an available ASBD struct:

- (void)recordData:(AudioBufferList *)data frames:(UInt32)numberOfFrames
{
    CMSampleBufferRef buff = NULL;
    CMFormatDescriptionRef format = NULL;
    OSStatus error = CMAudioFormatDescriptionCreate(kCFAllocatorDefault, &asbd, 0, NULL, 0, NULL, NULL, &format);

    CMSampleTimingInfo timing = { CMTimeMakeWithSeconds(1 / 44100.0, 1), kCMTimeZero, kCMTimeInvalid };
    error = CMSampleBufferCreate(kCFAllocatorDefault, NULL, false, NULL, NULL, format, numberOfFrames, 1, &timing, 0, NULL, &buff);

    error = CMSampleBufferSetDataBufferFromAudioBufferList(buff, kCFAllocatorDefault, kCFAllocatorDefault, 0, data);
    if ( error ) { NSLog(@"CMSampleBufferSetDataBufferFromAudioBufferList returned error: %ld", error); }


In the last line the error is '-12731': kCMSampleBufferError_RequiredParameterMissing. I'm not sure which that should be, there are so many?

Has anyone solved this before?

Thanks,

patrick
--
Patrick Machielse
Hieper Software

http://www.hieper.nl
email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Convert AudioBufferList to CMSampleBuffer
      • From: Heinrich Fink <email@hidden>
  • Prev by Date: Re: About how many channels of 16/44.1 PCM audio should I be able to stream from disk on an iPhone 4?
  • Next by Date: Re: About how many channels of 16/44.1 PCM audio should I be able to stream from disk on an iPhone 4?
  • Previous by thread: Re: Addin instrument data to caf files
  • Next by thread: Re: Convert AudioBufferList to CMSampleBuffer
  • Index(es):
    • Date
    • Thread