Re: How to configure AudioConverter to write VBR?
Re: How to configure AudioConverter to write VBR?
- Subject: Re: How to configure AudioConverter to write VBR?
- From: Stephen Davis <email@hidden>
- Date: Sun, 8 Feb 2009 16:05:32 -0800
On Feb 8, 2009, at 3:28 PM, Jens Alfke wrote:
I'm trying to get my ExtAudioFile-based export code to generate VBR
AAC files. In the SDK I found CAAudioFileConverter.cpp, which
configures VBR (it calls it the 'strategy') by setting the
AudioConverter's kAudioCodecBitRateFormat property. I added the
equivalent to my code, but it doesn't seem to be working — at least,
if I import the resulting files into iTunes, the Info window doesn't
say they're VBR.
It might actually be working. The MPEG-4 specification wasn't
perfectly clear on the indicator for VBR and many older devices won't
play files that are "correctly" indicated so the file is often stamped
with 128kbps when it's really not. In Leopard, CoreAudio switched to
stamping the real average bit rate in the file so you'll see things
like 133kbps which will also be shown by iTunes. You can also play
the track in QT Player which will calculate the true average bit rate
instead of believing what's stamped in the file. Lastly, check the
output of afinfo and see what it says.
To get around this issue, iTunes started writing a custom tag into the
file which contains the target bit rate, the VBR control mode, and
other bits which lets it show (VBR) in the Info panel where
appropriate. Not a perfect solution by any means but has the best
backwards-compatibility story. I don't recall what the state of
CoreAudio support for this is.
Any idea what I might be doing wrong? There are several possible
values for that property, so I chose
kAudioCodecBitRateControlMode_Variable, which the comment says is
usually the best tradeoff. I'm not getting any errors back when
setting that value, so it seems to be supported by the AAC encoder.
You want kAudioCodecPropertyBitRateControlMode =
kAudioCodecBitRateControlMode_VariableConstrained (smallish swing)
or
kAudioCodecPropertyBitRateControlMode =
kAudioCodecBitRateControlMode_Variable (wide swing)
There is also the kAudioCodecPropertySoundQualityForVBR which you
should set instead of kAudioConverterCodecQuality when using
kAudioCodecBitRateControlMode_Variable. That's a little confusing but
the docs do talk about it.
Also, you need to set the target bit rate via
kAudioCodecPropertyCurrentTargetBitRate which I assume you are already
doing.
Similarly, I've tried setting the encoding quality via the
kAudioConverterCodecQuality property, but I'm not sure whether it
has an effect. iTunes says "Low Complexity" either way. Is there any
way to tell, other than listening really hard to both versions on
expensive headphones?
Those are different. Low Complexity is the specific AAC variant that
is in play and has nothing to do with kAudioConverterCodecQuality.
Other types are Main Profile, Scalable Sampling Rate, Long Term
Prediction, etc. but iTunes only supports Low Complexity.
hth,
stephen _______________________________________________
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