Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8263303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:03:14+00:00 2026-06-08T04:03:14+00:00

I am trying to get the samples out of a CMSampleBufferRef and into an

  • 0

I am trying to get the samples out of a CMSampleBufferRef and into an array of floats in order to change the pitch. I have found a method CMSampleBufferCallForEachSample in the documentation but don’t know how to use it and there are no examples or explanations. Please I have been running around in circles with this thing for a while, can anyone help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T04:03:16+00:00Added an answer on June 8, 2026 at 4:03 am

    I was solving similar problem. I needed to split AAC samples from one SampleBuffer.

        ...
        CMSampleBufferCallForEachSample(sampleBuffer, &sampler, NULL);
        ...
    
    static OSStatus sampler(CMSampleBufferRef sampleBuffer, CMItemCount index, void *refcon) {
        CMTime presentationTimeStamp = CMSampleBufferGetOutputPresentationTimeStamp(sampleBuffer);
        CMBlockBufferRef buff = CMSampleBufferGetDataBuffer(sampleBuffer);
        UInt32 timeStamp = (1000*presentationTimeStamp.value) / presentationTimeStamp.timescale;
        size_t size = CMBlockBufferGetDataLength(buff);
    
        void *sampleData = malloc(size);
        CMBlockBufferCopyDataBytes(buff, 0, size, sampleData);
        NSData * data = [NSData dataWithBytes:sampleData length:size];
        NSLog(@"Audio %ldx samples of size %lu has been transfered at time %ld", CMSampleBufferGetNumSamples(sampleBuffer), size, timeStamp); 
    }
    

    but callback is called only once for first sample in each sampleBuffer, even there is the array of 76 samples and CMSampleBufferGetNumSamples returning this number

    i found excellent solution here (method fillMovieSampleBuffer row 283)

    for documentation of CoreMedia framework check this URL

    @function   CMSampleBufferCallForEachSample
    @abstract   Calls a function for every individual sample in a sample buffer.
    @discussion Temporary sample buffers will be created for individual samples,
    referring to the sample data and containing its timing, size and attachments.
    The callback function may retain these sample buffers if desired.
    If the callback function returns an error, iteration will stop immediately
    and the error will be returned.
    
    If there are no sample sizes in the provided sample buffer, kCMSampleBufferError_CannotSubdivide will be returned.
    This will happen, for example, if the samples in the buffer are non-contiguous (eg. non-interleaved audio, where
    the channel values for a single sample are scattered through the buffer).
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just trying out a couple of Android samples. Struggling to find the method managedQuery
I'm trying to get a string in my call from an array. But have
Trying to get comfortable with jQuery and I have encountered some sample code that
So my asp.net is very very rusty, and i'm trying to get back into
I've been trying to figure this out for a few hours now. In order
I've been tearing my hair out trying to get the AVFoundation camera to capture
I am trying to get an Current Altitude from location.getAltitude() method. but it always
I'm trying to get the sample and other sample codes i find for pyuno
I'm trying to get a basic sample across domains working, but I just cannot
While i am trying to get value from arraylist,i got the following errors.My sample

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.