Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
AACEncodingGuide FFmpeg
Lastmodified6daysago
FFmpegandAACEncodingGuide
AdvancedAudioCoding(AAC)is thesuccessorformattoMP3,and isdefinedinMPEG4part3 (ISO/IEC144963).Itisoften usedwithinanMP4container formatformusicthe.m4a extensioniscustomarilyused. Thesecondmostcommonuseis withinMKV(Matroska)files becauseithasbettersupportfor embeddedtextbasedsoft subtitlesthanMP4.Theexamples inthisguidewillusethe extensionsMP4andM4A.
Contents
libfdk_aac ConstantBitRate(CBR)mode VariableBitRate(VBR)mode HighEfficiencyAAC NativeFFmpegAACencoder libvo_aacenc libfaac Metadata FAQ WhichencodershouldIuse?Whatprovidesthebestquality? ShouldIuseAACLCorAACHE? Igetanerrorabout"experimentalcodecs".Whatdoesthismean? AlsoSee
FFmpegcansupportfourAACLCencoders(a a c , l i b f a a c , l i b f d k _ a a c , l i b v o _ a a c e n c )andtwo AACHEencoders(l i b a a c p l u s and l i b f d k _ a a c ).Thelicensesof l i b a a c p l u s , l i b f a a c ,and l i b f d k _ a a c arenotcompatiblewiththeGPLanddistributionofbinariescontainingcodelicensed undertheselicenseswhenGPLlicensedcodeisalsoincludedisnotpermitted.Thereforethese encodershavebeendesignatedas"nonfree",andyoucannotdownloadaprebuiltffmpegthat supportsthem.Thiscanberesolvedbycompilingffmpeg.
libfdk_aac
FraunhoferFDKAACcodeclibrary.ThisiscurrentlythehighestqualityAACencoderavailable withffmpeg.Requiresffmpegtobeconfiguredwith e n a b l e l i b f d k _ a a c (andadditionally e n a b l e n o n f r e e ifyou'realsousing e n a b l e g p l ).Butbeware,itdefaultstoalowpassfilter ofaround14kHz.Ifyouwanttopreservehigherfrequencies,use c u t o f f1 8 0 0 0 .Adjustthe numbertotheupperfrequencylimityouprefer.
ConstantBitRate(CBR)mode
Thesesettingstargetaspecificbitrate,withlessvariationbetweensamples.Itgivesyou greatercontroloverfilesize,anditiscompatiblewiththeHEAACprofile.Asaruleofthumb, foraudibletransparency,use64kb/sforeachchannel(so128kb/sforstereo,384kb/sfor5.1 surroundsound).Setthebitratewiththe b : a flag. Examples ConvertandaudiofiletoAACinanM4A(MP4)container: f f m p e gii n p u t . w a vc : al i b f d k _ a a cb : a1 2 8 ko u t p u t . m 4 a Convert5.1surroundsoundaudioofavideo,leavingthevideoalone: f f m p e gii n p u t . m p 4c : vc o p yc : al i b f d k _ a a cb : a3 8 4 ko u t p u t . m p 4 Convertthevideowithlibx264,withatargetoffittinga90minutemovieona 700MB(=5734400kb)CDROM,mixingtheaudiodowntotwochannels(Windowsusersshoulduse
https://trac.ffmpeg.org/wiki/AACEncodingGuide
1/4
11/16/13
AACEncodingGuide FFmpeg
N U L ratherthan / d e v / n u l l ):
VariableBitRate(VBR)mode
Targeta quality,ratherthanaspecific bitrate.1islowestqualityand5ishighestquality.Testit outandusethelowestsettingthatworksforyou.ThismodeisnotcompatiblewithAACHE,but forAACLC(thedefaultforffmpeg,andmostcompatibleAACprofile)itshouldprobablybe preferred,sinceitallowstheencodergreaterflexibilitytodistributebitsasitseesfit.Setthe VBRlevelwiththe v b r flag. Accordingtothishydrogenaudiopost,theVBRmodes(onaverage,overanumberoffiles)give thefollowingbitratesperchannel(soforstereo,doublethebitratefor5.1surroundsound, multiplyitbysix): VBR 1 2 3 4 5 kb/s/channel 32 40 4856 64 8096
Examples ConvertanaudiofiletoAACinanM4A(MP4)container: f f m p e gii n p u t . w a vc : al i b f d k _ a a cv b r3o u t p u t . m 4 a Converttheaudioonlyofavideo: f f m p e gii n p u t . m p 4c : vc o p yc : al i b f d k _ a a cv b r3o u t p u t . m p 4 Convertthevideowithlibx264,andmixdownaudiototwochannels: f f m p e gii n p u t . m p 4c : vl i b x 2 6 4c r f : v2 2p r e s e t : vv e r y f a s t\ a c2c : al i b f d k _ a a cv b r3o u t p u t . m p 4
HighEfficiencyAAC
ThisisapairofAACprofilestailoredforlowbitrates(version1andversion2).VBRmodeisnot compatiblewithAACHEsoabitrateisdeclared.AACHEversion1issuitedforbitratesbelow 64kb/s(forstereoaudio)downtoabout48kb/s,whileAACHEversion2issuitedforbitratesas lowas32kb/s(again,forstereo). Unfortunately,manydevicesthatcanplayAACLC(thedefaultprofilefor l i b f d k _ a a c )simply cannotplayeitherversionofAACHE,sothisisnotrecommendedforsurroundsoundaudio, whichnormallyneedstobecompatiblewithsuchhardwareplayers.Ifyouareonlygoingtoplay itonyourcomputer,oryouaresurethatyourhardwareplayersupportsAACHE,youcanaim forabitrateof160kb/sforversion1,or128kb/sforversion2.Asalways,experimenttosee whatworksforyourears.
https://trac.ffmpeg.org/wiki/AACEncodingGuide
2/4
11/16/13
AACEncodingGuide FFmpeg
NativeFFmpegAACencoder
ThenativeFFmpegAACencoderisincludedwithffmpegandisdoesnotrequireanexternal libraryliketheotherAACencodersdescribedhere.Notethatyouwillnotgetasgoodresultsas with l i b f d k _ a a c .Thisisconsideredanexperimentalencoder,so s t r i c te x p e r i m e n t a l or s t r i c t2 isrequired. Exampleusingq : a f f m p e gii n p u t . w a vs t r i c te x p e r i m e n t a lc : aa a cq : a6o u t p u t . m 4 a Effectiverangefor q : a isprobably0.110(unverified).Ifffmpegignores q : a thengetanewer build(seeticket#1346). Exampleusingb : a f f m p e gii n p u t . w a vs t r i c te x p e r i m e n t a lc : aa a cb : a2 4 0 ko u t p u t . m 4 a Note: c u t o f f1 5 0 0 0 waspreviouslyrecommendedforthisencoder,butthisisnow automaticallyappliedsince2012July.
libvo_aacenc
VisualOnAACencodinglibrary.Requiresffmpegconfigurationwith e n a b l e l i b v o a a c e n c .This hastheadvantageofnotbeingnonfree,andisincludedbysomedistributors,butisarather poorencodercomparedto l i b f d k _ a a c andeventhenativeFFmpegAACencoderaccordingto QualityAssessmentofFFmpegAACandamailinglistpost.Thisencodersupportsupto2 channels,isCBRonly,anddoesnotworkwith q : a /q s c a l e : a . f f m p e gii n p u t . w a vc : al i b v o _ a a c e n cb : a1 2 8 ko u t p u t . m 4 a
libfaac
FreewareAdvancedAudioCoder.Requiresffmpegconfigurationwith e n a b l e l i b f a a ce n a b l e n o n f r e e .Notethatyouwillnotgetasgoodresultsaswith l i b f d k _ a a c . VariableBitRate(VBR)Example
https://trac.ffmpeg.org/wiki/AACEncodingGuide
3/4
11/16/13
AACEncodingGuide FFmpeg
Metadata
Youcanaddmetadatatoanyoftheexamplesonthisguide:
FAQ
WhichencodershouldIuse?Whatprovidesthebestquality?
ForAACLCthelikelyansweris: l i b f d k _ a a c > l i b f a a c >NativeFFmpegAACencoder(a a c )> l i b v o _ a a c e n c .
ShouldIuseAACLCorAACHE?
Ifyourequirealowaudiobitrate,suchas32kbs/channel,thenAACHEwouldbeworth consideringifyourplayerordevicecansupportAACHEdecoding.Anythinghighermaybenefit morefromAACLCduetolessprocessing.IfindoubtuseAACLC.AllplayerssupportingAACHE alsosupportAACLC.
Igetanerrorabout"experimentalcodecs".Whatdoesthismean?
Someencoders,suchasthenativeFFmpegAACencoder(a a c ),areconsideredexperimentaland requiretheadditionof s t r i c te x p e r i m e n t a l or s t r i c t2 (samething,differentname)to yourcommandasanoutputoption.Otherwiseyoumaysee:
AlsoSee
Guidelinesforhighqualitylossyaudioencoding
https://trac.ffmpeg.org/wiki/AACEncodingGuide
4/4