I am using external camera which records both audio and video.
My app receives the audio in AAC format with the following struct:
struct AudioPacket {
let timestamp: TimeInterval
let data: Data
let asbd: AudioStreamBasicDescription
let magicCookie: Data
let audioSpecificConfigData: Data
}
The AudioStreamBasicDescription
property has the following content:
- mSampleRate : 48000.0
- mFormatID : 1633772320
- mFormatFlags : 0
- mBytesPerPacket : 0
- mFramesPerPacket : 1024
- mBytesPerFrame : 0
- mChannelsPerFrame : 1
- mBitsPerChannel : 0
- mReserved : 0
I am writing both audio and video into a file using AVAssetWriter
and need to provide CMSampleBuffer
-s to the asset writer.
So how can I convert the above AudioPacket
struct to CMSampleBuffer
?