Hello,
As explained in this link, the AVAssetReaderTrackOutput.copyNextSampleBuffer()
returns a CMSampleBuffer
in linear PCM audio format.
I want to place this audio buffer into an AVAssetWriterInput
of type kAudioFormatMPEG4AAC
, but I can't manage the conversion.
Could you help me by providing an extension that returns a CMSampleBuffer
converted from linear PCM audio format to kAudioFormatMPEG4AAC
?
Example:
extension CMSampleBuffer {
func fromPCMToAAC() -> CMSampleBuffer? {
// Here, get a new AudioStreamBasicDescription, create a CMSampleBuffer and a CMBlockBuffer
}
}
I've tried multiple times but without success.
Software: iOS 18.1 XCode: 16.0 Thank you!