Sei sulla pagina 1di 4

11/16/13

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 ):

f f m p e gyii n p u t . m p 4c : vl i b x 2 6 4b : v9 3 3 kp r e s e t : vv e r y f a s tp a s s1a n/ d e v / n u l f f m p e gii n p u t . m p 4c : vl i b x 2 6 4b : v9 3 3 kp r e s e t : vv e r y f a s tp a s s2\ a c2c : al i b f d k _ a a cb : a1 2 8 ko u t p u t . m p 4

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

AACHEversion1 f f m p e gii n p u t . w a vc : al i b f d k _ a a cp r o f i l e : aa a c _ h eb : a6 4 ko u t p u t . m 4 a AACHEversion2 f f m p e gii n p u t . w a vc : al i b f d k _ a a cp r o f i l e : aa a c _ h e _ v 2b : a3 2 ko u t p u t . m 4 a

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

f f m p e gii n p u t . w a vc : al i b f a a cq : a1 0 0o u t p u t . m 4 a Rangefor q : a is10500andissimilartousingthe q optioninstandalone f a a c .100isagood valuetotry. AverageBitRate(ABR)Example f f m p e gii n p u t . w a vc : al i b f a a cb : a1 9 2 ko u t p u t . m 4 a l i b f a a c doesnotsupportatrueConstantBitRate(CBR)mode.

Metadata
Youcanaddmetadatatoanyoftheexamplesonthisguide:

f f m p e gii n p u t. . .m e t a d a t aa u t h o r = " F F m p e gB a y o uJ u gB a n d "m e t a d a t at i t l e = " D e c o d e

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:

T h ee n c o d e r' a a c 'i se x p e r i m e n t a lb u te x p e r i m e n t a lc o d e c sa r en o te n a b l e d ,a d d' s t r i

AlsoSee
Guidelinesforhighqualitylossyaudioencoding

https://trac.ffmpeg.org/wiki/AACEncodingGuide

4/4

Potrebbero piacerti anche