I am currently using AVAssetWriter to create Quicktime mov. The video track is generated correctly. Now I would like to add the mp4a trash soundtrack. The sound may just be white. I am mainly interested in the mov file, which contains both video and audio tracks.
How to configure a CMSampleBufferRef that just contains white noise in mp4a format? Here is what I have 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,
When NULL is passed for audioFormatDescrip, the mov file is generated successfully, but contains only the video track (and the absence of an audio track). When I actually pass audioFormatDescrip, the mov file seems corrupted. I probably should really pass some samples, but I'm not sure how to do this.
Note. I checked that appendSampleBuffer returns YES (for brevity, I skipped this code).
source share