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

  • SEARCH
  • Home
  • 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 6754235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:15:20+00:00 2026-05-26T13:15:20+00:00

I’m currently using AVAssetWriter to generate a Quicktime mov. The video track is generated

  • 0

I’m currently using AVAssetWriter to generate a Quicktime mov. The video track is generated correctly. Now I’d like to add a “garbage” mp4a audio track. The audio can just be white noise. What I’m mainly concerned with is the mov file containing both video and audio tracks.

How do I setup a CMSampleBufferRef that just contains white noise in mp4a format? Here’s what I’ve tried so far:

CMSampleBufferRef garbageAudioSampleBuffer = NULL;

AudioStreamBasicDescription audioFormat;
audioFormat.mSampleRate = 44100;
audioFormat.mFormatID   = kAudioFormatLinearPCM;
audioFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
audioFormat.mFramesPerPacket = 1;
audioFormat.mChannelsPerFrame = 2;
audioFormat.mBitsPerChannel = 16;
audioFormat.mBytesPerPacket = 4;            
audioFormat.mBytesPerFrame = 4;

CMAudioFormatDescriptionRef audioFormatDescrip = NULL;
CMAudioFormatDescriptionCreate(kCFAllocatorDefault, 
                               &audioFormat, 
                               0, 
                               NULL,
                               0, 
                               NULL, 
                               NULL, 
                               &audioFormatDescrip
                               );

CMSampleBufferCreate(kCFAllocatorDefault, 
                     NULL,
                     YES, 
                     NULL, 
                     NULL, 
                     NULL, // audioFormatDescrip,
                     0,
                     0, 
                     NULL, 
                     0, 
                     NULL, 
                     &garbageAudioSampleBuffer
                     );

if(myAVAssetAudioWriterInput isReadyForMoreMediaData)
    [myAVAssetAudioWriterInput appendSampleBuffer:garbageAudioSampleBuffer];

When NULL is passed for the audioFormatDescrip the mov file is generated successfully but contains only a video track (and no audio track). When I actually pass audioFormatDescrip the mov file seems to be corrupted. I probably have to actually pass some samples but I’m not sure how.

Note: I’ve verified that appendSampleBuffer returns YES (for brevity I omitted that code).

  • 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-05-26T13:15:21+00:00Added an answer on May 26, 2026 at 1:15 pm

    There are a bunch of problems in your code:

    1. White noise has a statistical definition, you’re creating undefined noise.
    2. You’re not passing the audioFormatDescription to CMSampleBufferCreate
    3. You’re complicating your life by using CMSampleBufferCreate instead of CMAudioSampleBufferCreateWithPacketDescriptions (you don’t have packet descriptions, so just past null & 0)
    4. You need to say when your audio buffer is with a Presentation Time Stamp
    5. Your audio buffer is 0 frames long. That’s too short.
    6. and finally, you need to keep adding audio buffers, enough for the whole duration of your film

    CoreMedia code can be tricky because there are hundreds of arguments that need to be just right. For your purposes it may be a little too general, so why not get a loopable snippet of white noise and assemble it using an AVMutableComposition? This will give you a film & and an audio file which you can then zip together using another AVMutableComposition and an AVAssetExportSession.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from

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.