Re: Using AudioConverter to create compressed audio
Re: Using AudioConverter to create compressed audio
- Subject: Re: Using AudioConverter to create compressed audio
- From: Neil Clayton <email@hidden>
- Date: Fri, 25 Jan 2008 19:22:07 +1300
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Brad,
Thanks for clearing up the part re the magic cookie.
I did indeed find a bug in regarding input sizing, within the input
proc.
Here's the code that sets up the buffers going out of the input proc
(after filling them with some data):
for(int i = 0; i < MIN(audioConverterBuffer->mNumberBuffers, buffer-
>mNumberBuffers); i++) {
UInt32 dataSize = read * inASBD.mBytesPerFrame;
buffer->mBuffers[i].mData = audioConverterBuffer->mBuffers[i].mData;
buffer->mBuffers[i].mDataByteSize = dataSize; // *** Here's where I
was wrong, passing in (incorrectly) audioConverterBuffer-
>mBuffers[i].mDataByteSize
buffer->mBuffers[i].mNumberChannels = audioConverterBuffer-
>mBuffers[i].mNumberChannels;
}
I was telling the AudioConverter the total capacity of each buffer,
as opposed to telling it how much data I'd just provided for it.
This has moved me along somewhat. I'm now able to record in any kind
of format that I like.
Thanks for the help.
--
Regards,
Neil Clayton
On 24/01/2008, at 8:31 PM, Brad Ford wrote:
On Jan 23, 2008, at 9:48 PM, Neil Clayton wrote:
I'm attempting to use AudioConverter to create compressed data from
PCM data.
The input ASBD comes out from the AU that is receiving the data
(I'll be passing a copy of the data this AU receives, so in effect
splitting off at that point and compressing the same thing), The
output ASBD is from the QT SCAudio component. The audio
converter initializes OK, and I'm able to successfully set it's
magic cookie.
At this stage I'm compressing PCM to AAC.
Hold on there. Typically magic cookies are not for setting on the
output side of an audio converter. They are for telling an audio
converter about compressed _input_ buffers when you're
decompressing. Typically a magic cookie on output is insufficient
to configure an encode. You should be getting the
kQTSCAudioPropertyID_CodecSpecificSettingsArray and passing it to
the audio converter as the kAudioConverterPropertySettings. There
are a few legacy encoders that have no
kQTSCAudioPropertyID_CodecSpecificSettingsArray, but do have a magic
cookie. For these, it's ok to pass the
kQTSCAudioPropertyID_MagicCookie from SCAudio to the audio converter
as the kAudioConverterCompressionMagicCookie, but AAC is not one of
them. So you should be using the
kQTSCAudioPropertyID_CodecSpecificSettingsArray property instead.
There's a technote about this: http://developer.apple.com/qa/qa2006/qa1390.html
<SNIP>
So here I copy some frames from the internal queue, and then make
the passed in buffer reference that queue (the AudioBufferList
passed by the audio buffer appear to have the right number of
buffers (2) for the PCM data, but are not initialized in any other
way).
So the flow is AU -> Internal conversion queue -> AudioBufferList -
> AudioConverter.
Where in the last case the audio converter always receives a
reference to the AudioBufferList data pointers. It's always PCM
data going in.
This appears to all go as planned - except that I get
kAudioConverterErr_InvalidInputSize back from the call to
AudioConverterFillComplexBuffer.
kAudioConverterErr_InvalidInputSize usually means your
mDataByteSize's are wrong in the audiobufferlist you're filling out
in your inputProc. Do they jibe with the number of data packets
you're saying that you're returning?
-Brad Ford
QuickTime Engineering
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden