326 16 788KB
English Pages 54
WHITE PAPER
CompressionPrimer Introduction Thisprimerisforanyonelearninghowtopreparehigh-qualitycompressedvideofiles.Itisfor webandvideoprofessionalswhoarenewtocompression,andforpeoplewhowanttoimprove theirskills.Compressionisoftenperformedatthelastminute,sofeelfreetoskiptothesection coveringtheformatandcodecsyoucareabout.
TABLEOFCONTENTS 1 Introduction 2
Gettingstartedwith compression
3
Understandingthe fundamentalsofcompression
4
Typesofcompression
5
Frametypesandcompression
6
Colormodes
6
Colordepths
7
Colorsampling
8
Audiocompression
9
Compressionefficiency
9
Authoringvideoforfuture compression
12 Capturingvideo:choosing formatsandconnections 13 Choosingtherightcapture codec 14 Exportingvideo 15 Understandingpreprocessing 17 Cropping 17 Scaling 18 Noisereduction 19 Imageprocessing 20 Audioprocessing 21 Encoding 25 Deliverymethodsforvideo 27 Choosingacompression format
28 ExportingtoWindowsMedia format 29 WindowsMediaplayers 30 WindowsMediaencoding modes 32 WindowsMediavideocodecs 33 WindowsMediaaudiocodecs 34 ExportingtoRealMediaformat 34 RealMediavideocodecs 35 RealMediaaudiocodecs 36 ExportingtoQuickTimeformat 37 QuickTimevideocodecs 42 QuickTimeaudiocodecs
45 ExportingtoMPEG-1format
Gettingstartedwithcompression Thebeststartingpointforlearningabouthowtoachievegreatresultsfromcompressionisto understandwhyandhowit’sdone.Whilethemathematicalbasesofcompressionareverycomplex,thebasicprinciplesarequiteapproachable.Themainreasonyouneedtocompressvideois becauseuncompressedvideoisfartoolargetotransporteffectively. Bitstreamtype
Datarate(Kilobitspersecond)
Timeonone700MBCD-ROM
Uncompressedhighdefinition (1920x108029.97fps)
745750
7.5seconds
Uncompressedstandarddefinition (720x48629.97fps)
167794
33seconds
DV25(miniDV,DVCAM,DVCPRO)
25000
3min,44seconds
TypicalDVD
5000
18min,40seconds
VideoCD
1167
80minutes
Broadbandwebvideo
100-2000
(500Kbps) 3hours,8minutes
Modemwebvideo
18-48
(32Kbps) 48hours,37minutes
46 MPEG-1videoandaudiocodec 46 ExportingtoDVDandMPEG-2 formats 47 MPEG-2audiocodecs 48 ExportingtoMPEG-4format 50 MPEG-4audiocodecs 51 ExportingtoAVIformat 51 AVIvideocodecs 52 AVIaudiocodecs
Compressionefficiency Thetoptworowsofuncompressed videoaresubstantiallylargerinsize andshorterindurationthanthe compressedvideointhelastfive rows.
Theratiosbetweendataratesusedforauthoringvideoandfordistributingcompressedvideo arehuge.Forexample,convertingfromdigitalvideo(DV)toDVDtypicallyentailsa5:1compression,andconvertinganuncompressedsourcetoamodem-compatiblevideousesabout 9000:1compression.Thatleavesonlyabout0.1%oftheoriginaldataleft.It’salmostamazing thatvideoontheweblooksandsoundsasgoodasitdoes! Inaddition,differenttypesofcompressedvideovaryinbitrate.Forexample,inwebvideo, thereisabouta100:1ratiobetweenthelowendofmodemratestothehighendofbroadband rates. CompressionandDVDformats MoreAmericanswatchcompressedvideoonDVDthanonanyothermedia.(Digitalbroadcasts overcableandsatellitearecloserunnersup.) ModernDVD-Rburnerscanput4.7GBofdataonadisc(calledaDVD-5).Manufactured DVDscanuseadual-layerformatthatcanhold8.54GB(calledDVD-9)ofdata,whichburners donotsupportyet.EvenwithaDVD-5,it’spossibletoputahigh-qualitytwo-hourmovieona disc. ThekindofDVDthatplaysinaDVDplayerismoreaccuratelyknownasDVD-Video.There isalsoDVD-ROM,whichisacomputer-formatteddiscthatrequiresacomputertoplayit—in effect,it’salargecapacityCD-ROM.TherearealsohybridDVD-Video/DVD-ROMdiscs,which playinnormalDVDplayers,butalsoincludeinformationonlyavailableforcomputerplayback. DVD-VideodiscsaremasteredineitherNTSC(theformatusedintheU.S.andJapan)orPAL (theformatusedinEuropeandAsia).Aset-topplayer(suchasyourhomeDVDplayer)forone formattypicallywon’tplaydiscsintheotherformat;however,computerscantypicallyplay discsofbothtypes.DVDscanalsoberegioncoded,sotheyonlyplayinDVDplayersorsoftwareintendedforacertainregion.Regioncodingisanoptionalfeature. CompressionPrimer
2
CompressionandVideoCDformats VideoCDisanolderdisc-basedformat.IthasamuchlowerresolutionanddataratethanDVD, anditprovideslowerquality.However,itusesstandardCDmedia,soVideoCDdiscscanplay inavastvarietyofdevices,includingmostpersonalcomputers.AmanufacturedVideoCDcan playinanyDVDplayer. LikeDVD,VideoCDdiscscanbeeitherNTSCorPAL.VideoCDisverypopularinPAL countries,especiallyinAsia.AlsolikeDVD,softwareplayerssupportbothformats,andmany set-topplayersonlysupportone. CompressionandCD-ROMformats Startingintheearly1990s,CD-ROMvideowasapopularmedium.Whilethewebhaslargely replacedCD-ROMasamediumforinteractivecontent,peoplestilluseCD-ROMvideofor manyapplications,likecomputergamesandkiosks.Comparedtowebvideo,CD-ROMoffers muchhigherbandwidththanbroadbandconnectionsandiscapableofDVDqualityonfast computers. CompressionandInternetformats Videoonthewebisthehottestareaforongoingdevelopmentofcompressedvideotechnologies. Themainreasonisthatthebandwidthavailableonthewebismuchlessthanondiscs,soitis criticaltomakeeverybitcount.Anotherfactoristhatit’spossibletodistributeupdatedplayer softwaretocomputers,whichisn’tpossiblewithconsumerelectronicdevices,likeaDVD. Webvideocanuseeitherthereal-timestreamingmodeorprogressivedownloadmode.Realtimestreamingfilesplayinrealtimebutrequirespecializedstreamingserversoftwareandare limitedinqualitybytheavailablebandwidth.Progressivedownloadfilescomeoffstandardweb serversandmaytakealongtimetodownload,buttheymayprovidehigherandmorereliable videoandaudioquality.Understandingthedifferencesbetweenthesemodes,andthestrengths andweaknessesofeach,isamajorthemeofthisPrimer. Compressionandmobiledevices Mobiledevices,suchaspersonaldigitalassistants(PDAs)andmoderncellphonescreatea newareaforcompressedvideo.Thesedeviceshavesmallscreensandslowprocessors,even comparedtoalaptop,buttheabilitytoplayvideobackonadevicewithaweightmeasuredin ounces(notpounds)canhavealotofvalueforsomemarkets. Mostformatsforcompressedvideohaveplayersforsomemobiledevices,includingMPEG-4, Microsoft®WindowsMedia,andRealMedia.Dedicatedmobileformats,likeKinoma,arealso available. Inmanyways,videoonmobiledevices,especiallycellphones,isreminiscentoftheearlydays ofvideoondesktopcomputers.Thetechnologyisstillevolving,butit’samazingtoseeitwork. Today,therearen’tanyuniversalformatsorevensettingsformobiledevices.Instead,content hastobetunedtoasmallclassofdevicesorevenaparticularmodel.Butwhenthatworks,the resultscanbegreat.Mobilevideoisrapidlymaturingandshouldbecomeeasiertocompressat ahigherqualityoverthenextfewyears.
Understandingthefundamentalsofcompression Compressiontoolsandformatshidethemathematicalcomplexityofcompressionfromthe user,buttoachievethebestresults,youneedtounderstandthefundamentalsofwhyandhow compressiontoolsandformatsoperate. CompressionPrimer
3
Howweseeandhear Lackingvideoadaptersandaudioportsinourheads,wedon’tdirectlyperceivevideooraudio, compressedornot.Instead,weuseoursensesofsightandhearing,whicharepowerful,but havelimitationsthatmakecompressionpossible. Theeyeisoftendescribedasacamera,butthehumanvisualsystemincludesboththeeye andthebrainandismassivelymorecomplicatedandintertwinedthanasimpleCCD-to-tape device.Thewholesensorysystemistunedaccordingtotheevolutionaryenvironmentofour ancestors.Thus,humansareskilledatnoticingmotion,likeasaber-toothedtigerjumpingout ofajungle,orthedifferencebetweenripeandunripefruitbycolor.Butwearen’tskilledatseeinghighmotionanddetailatthesametime,orhighmotionandcoloratthesametime.Inthe sameway,hearingispowerful,butithasitslimitations.Wemayeasilyhearasoundinaquiet environmentbutnothearitinaloudone.Humanearsarebestattunedtothefrequencies ofhumanspeechandarelessawareofhigherorlowertones.Compressiontechnologiestake advantageofthestrengthsandweaknessesofhumansensestospendtheavailablebitsonthe informationthathumansperceivemoreacutely. Howcompressionworks Fundamentally,compressionworksbysummarizingthesequencesofimagesandsoundsas efficientlyaspossible.Filesencodedfordeliverydon’tprovideanidenticalrepresentation ofthesourcebacktotheuser—thedatarateswouldbefartoohigh.Instead,theencoded filesdescribetheimportantdetailsofthecontentasterselyaspossiblewhilestillproviding areproductionthat,tothehumansensorysystem,providestheexperienceoftheoriginalas accuratelyaspossible. Amatchedpairofacompressorandadecompressor,betterknownasacodec,performsthe compression.It’simportantthatthepairbematchedbecausethedecoder(decompressor) needstounderstandtheencoder’s(compressor’s)summaryofthedata.
Typesofcompression Videocodecscanusespatialcompression,temporalcompression,oracombinationofboth. Spatialcompression Spatialcompressionaffectsonlyasingleframeatatime,alsocalledintraframecompression. Mostauthoringcodecsonlyusespatialcompression,sotherearen’tanyinterdependencies amongframes.Thistypeofcompressionmakesrandomaccessandeditingeasy. Spatialcompressionfindsredundancywithinaframe—eitherinareasofflatorsimilarcolors orareasofaframethatlooklikeotherareasoftheframe. ManycodecsarebasedaroundatechniquecalledDiscreetCosineTransformation(DCT). Thesecodecsdealverywellwithsmoothgradationsinanimage,buttheycanhavetrouble encodingrandomdetailsorsharpedgesatlowerbitrates.DCT,orsimilartechniquestryingto encodeoverlycompleximagesattoolowofadatarate,causetwoofthemostcommonkinds ofartifacts:ringingandblocking.Onecommonareaoftroubleissmalltextwithsharpedges. Somecodecsuseverydifferentbasetechnologies,likewavelet,andthereforedealbetterwith sharpedges. Temporalcompression Temporalcompressionaddstheabilitytouseotherframesasareferenceforthecurrentframe. Inmostvideo,amajorityoftheframesaresimilarenoughtotheframeprevioustothemthat temporalcompressionisapplicable.
CompressionPrimer
4
Temporalcompressiongetsalotofresearchattentionandhasthemostroomforfuture improvements.
Frametypesandcompression Youcanrevealmanyfundamentalconceptsofcompressionbylookingatthekindsofframesin afile.Dependingonthecodecandmode,one,two,orthreekindsofframesmaybeinafile. AboutKeyframes(I-frames) AKeyframe,orI-frame(Intraframe),isaself-containedimage.AnI-frameisn’tbasedonany otherframesinthefile.ThefirstframeofamovieisalwaysanI-frame. Fordeliverycodecs,mostframesaren’tI-framesbecausetheydon’tofferasmuchcompression efficiencyasotherframetypes,whichareabletoreuseelementsthatarerepeatedinmultiple frames. I-framesareimportantforrandomaccessbecausethey’retheonlyframesthatcanbedecoded allbythemselves.Skippingtoaframethatisn’tanI-framemeansthattheframestheI-frameis basedonmustalsobedecoded,andtheframesthoseP-framesrefertomustbedecoded,andso on.AsthefrequencyoftheI-framesincreases,thenumberofframesthatneedstobedecoded decreases. Mostauthoringcodecs,likeMotionJPEGandDV,areI-frameonly.Editingiseasywith I-framesbecauseyoucanreassembleframeswithoutregardfortheotherframestheymightbe basedon. AboutDeltaframes(P-frames) ADeltaframe,orP-frame(Predictiveframe)inMPEG,isn’tself-containedlikeakeyframe. Instead,theframeisbasedontheframebeforeit,andonlychangesfromthepreviousframeare encoded.So,iftwoframesaremathematicallyidentical,andthesecondoneisaP-frame,itwill requireonlyafewbitstoencode.Butiftheframesarecompletelydifferent,aP-framewillbe aslargeasanI-frame(andmostcodecsautomaticallymaketheframeanI-frame).Fortypical content,aP-framemightbeonly10-20%thesizeofthesameframeatthesamequalityasan I-frame. Codecsvaryinhowwelltheyencodedifferentkindsofchangesamongframes.Forexample, fadesupanddownareverydifficultforsomecodecs,butsomenewercodecshavecodebuiltin tohandlefades. AboutBidirectionalframes(B-frames) ABidirectional,orB-frame,ismainlyusedinMPEGformats.AB-framecanuseimageelementsfromtheframesoneithersideofit,whichimprovescompressionefficiency.However, B-framescannotuseimageelementsfromotherB-frames.Thisrestrictionavoidsframesbeing basedonframesthatarebasedonthefirstframe—animpossiblerecursiveloop.
CompressionPrimer
5
Puttingalltheframestogether So,B-framescanbebasedonpreviousorfollowingP-framesandI-frames;P-framescanbe basedonapreviousI-frameoraP-frame;andI-framesaren’tbasedonanything. IBBPinterrelationship Atypical15-frameOpenGOPas usedinaNTSCDVD.Notethatin anOpenGOP,thetrailingB-frames canrefertothefirstI-frameofthe nextGOP.
Colormodes Whileitmightseemesoteric,thedifferentwaysthatcodecsdescribecolormatteragreatdealin practice.Theycanbeasourceofconfusingterminologyinthevideoworld. Therearethreebasictypesofcolorintoday’scodecs: •MonochromeInamonochromemode,onlyluminance(brightness)matters.Thiscolortype worksgreatforblack-and-whitemovies.Mostvideocodecsdon’thaveanexplicitgrayscale mode.NotableexceptionsareCinepakandJPEG(although,notalltoolsexposethecolor spacecontrol). •Red,Green,Blue(RGB)ComputerscreensandtelevisionsarenativelyRGB—thescreenhas red,green,andbluephosphorsforCRTsandplanesforLCDs.RGBisn’tveryefficientfor videocontent,soRGBcodecsaren’tusedforvideodeliveryanymore.However,RGBiswidely usedforscreenrecordingsandmotiongraphics. •Y'CbCr(alsocalledYUV,althoughYUVproperlyonlyreferstohowcolorisusedinNTSC video)Thesecodecsencodeluminanceandtwocolor-differencechannels(thesametechniqueusedintheAdobe®Photoshop®LABmode).Becausetherearethreecolors,youcan convertY'CbCrtoRGBfordisplay.Byseparatingoutthechromaandlumachannels,youcan keepthecriticallumainformationatfullresolutionanduselessresolutionforthechroma information.Thisprocessgreatlyreducesdatarateandprocessingrequirements.Youcan convertRGBtoandfromY'CbCradequately,buttherearealwayssomecolorsthatareavailableinonemodebutnottheother,andtherearealwaysroundingerrorsaspartoftheconversion.Byworkingintoolsthatsupport16-bit-per-channelRGB,likeAdobeAfterEffects®6 software,yousignificantlyimprovethequalityofthisconversion. Note:CMYK,whichstandsforCyan,Magenta,Yellow,andblacK,isthestandardintheprintingindustry,butitisn’tusedinvideo.
Colordepths Colordepthsdefinetheprecisionofthecolorsandmeasurehowmanygradationsofintensity thereare.Colordepthsfallintothefollowingcategories: •8-bit(indexed)color(oftencalled8-bitor256color)Earlycolorcomputersusedindexedcolor. Insteadofeachpixelhavingameasurementforred,green,andblue,eachpixelwasassigneda code,andalook-uptabletranslatedthatcodetoactualRGBvalues,whichthecomputercould
CompressionPrimer
6
display.Somecodecssupportedevenlowermodes,like4or16colors,providingaverysimple compressionschemebyreducingthenumberofbitsrequiredtostoretheimage.The8-bit colordepthdoesn’tworkwellforvideosourcebecauseeventhesimplestscenesusemorethan 256colors.Theonlysignificantformatthatstillrequires8-bitisGIF. •5bitsperchannel(oftencalledThousandsofColorsorHighColor)Afterthe8-bitera,the mostcommonconsumerbitdepthwas5bitsperchannel.OnMacintoshcomputers,thiswas exactly5bitsperred,green,andblue,withonebitreservedforanalphachannel.Microsoft Windows®gaveanextrabittogreen,whichimprovedlumaquality,butleftnoroomforan alphachannel.The5-bitcolormodewasusedforsomeancientvideo-compressioncodecs. Today,itismainlyusedforscreenrecordingapplicationswhereitmayprovidebettercompressionandperformancethan8bitsperchannelwithoutanyobviousdegradation. •8bitsperchannel(alsocalledMillionsorTrueColor)Allmodernvideo-compressioncodecs usethismode.Itissometimescalled24-bitor32-bitmode.The32-bitmodeisstill8bitsper channelbutwithanaddedalphachannel. •10bitsperchannelThismodeisusedinhigh-endY'CbCrauthoringsystems,likeDigital Betacam,D1,andsomeanalogcapturecards.Itprovides1024gradationsinsteadof256, whichreducesbanding,especiallywithmultiplegenerationsofeffects.Itisn’tusedinany deliveryformats,althoughsomeauthoringcodecssupportit.The10-bitY'CbCrmode providesfourtimesmoreaccuracythan8bitwhenconvertingtoorfrom16-bit-per-channel RGBinAfterEffects. •16bitsperchannelSomehigh-endapplicationsusethismodetopreservemorecolordetail. Thismodeisespeciallyusefulwhendoingmultiplegenerationsorwhenconvertingfromand thenbacktoY'CbCr.AfterEffects6supports16-bit-per-channelprocessingforRGB.Video thatissavedat16bitsperchannelisneverdirectlydeliveredtousers.
Colorsampling Y'CbCrformatssupportcolorsubsampling.Colorsamplingrecordsfewerpixelsofchroma informationthanlumainformation.Theterminologyforcolorsamplingisconfusingbecause itusesanX:Y:Zformat.Thefirstvalueisthenumberoflumasamplesthataredescribed—this isalmostalwaysfour.Thesecondvalueisthenumberofchromasamplesperlumasampleon thefirst,third,fifth,andsucceedingoddlines.Soifthisvalueistwo,therearetwochroma samplesperfourlumasampleshorizontally.Thelastvalueisthenumberofchromasamplesper lumasampleonthesecond,fourth,sixth,andsucceedingevenlines.Ifthisnumberiszero,the chromasamplefromthefirstlineisused. •4:4:4Chromaissampledeverypixelwithnosubsampling.Y'CbCrdeliverycodecsdon’tuse thisformatbecauseitusesalotofbitsanddoesn’tprovideanyadditionalapparentquality.In authoringapplications,itissometimesinternal.RGBisalways4:4:4. •4:2:2Thisformatisusedforhigh-endvideoauthoring,informatslikeDV50,DigitalBetacam, D1,andMotionJPEG.AfewdeliverycodecslikeH.263useitaswell. •4:2:0Thevastmajorityofdeliverycodecsusethisformat.Thereisonechromasampleper 2x2blockofpixels.Thischromasamplelooksnearlyasgoodas4:4:4,butathalfthebitsper frame.ItisalsousedforPALDV(butnotPALDVCPRO). •4:1:1NTSCDVandPALDVCPROusethisformat.Itcontainsthesamenumberofbitsper frameas4:2:0butwithonesampleper4x1blockofpixels.Thisformatisbetterforinter-
CompressionPrimer
7
lacedcontentbecauseeachfieldgetsitsownsample;however,itcanresultinvisiblechroma artifactsinareasofhighsaturation,whichcanbeaproblemwithbluescreenormotiongraphicssource. •YUV-9Thisformathasonechromasampleper4x4blockofpixels.Thisformatresultsin noticeablydegradedquality,soitisn’tusedinmoderncodecs.Legacycodecsthatuseitinclude theIndeofamilyandtheoriginalversionofSorensonVideo.(SorensonVideo3uses4:2:0.) Colorsubsampling Themostcommontypesofcolor subsampling.
Audiocompression Whileaudiomayuseonlyasmallfractionofthebitsinacompressedfile,itisresponsibleforhalf oftheexperience.Weshouldn’tneglectitsimportance. Samplingrate Themostfundamentalfactorinaudioissamplingrate,whichismeasuredinHertz(Hz),or cyclespersecond.AudioCDsuse44100Hz,or44.1KHz,whichprovidesexcellentreproduction. Samplerate
Used
Sufficientfor
8KHz
Phonesystem
Speech
11KHz
Oldmultimediastandard
Betterspeech
22.050KHz
Alsooldmultimediastandard
Recognizablemusic
32KHz
Commoninbroadbandvideo
Minimumfordecentmusic
44.1KHz
AudioCD
Music
48KHz
DVD,DAT
Music
96KHz
High-endaudiorecording
Highfidelitymastering
Sampleratechart Typicalsampleratesforcommon uses.
Bitdepth Bitdepthdeterminestheprecisionofaudiovolumeatanygivensample—ithasamassiveeffect onaudioquality. •8bitOriginally,multimediaaudioused8bit,whichmeanstherewasameasurementofvolume from0-256foreachsample.Thisbitdepthwasn’tnearlyenoughfordecentquality,whichled totheharshqualityofearlyCD-ROMtitles.Thereisnoreasontodistributeaudioas8bitanymore.Modern16-bitcodecsprovidebetterqualityatasmallerfilesizethan8-bitcodecswere everableto. CompressionPrimer
8
•16bitThisbitdepthisthecurrentstandardforaudiodistribution.Mostmoderncodecsare16 bit,andaudioCDsare16bitaswell. •20bitThisbitdepthisusedforprofessionalaudiorecordingtogiveabetterdynamicrange than16bit.Codecsthatsupport24-bitaudio(describedlater)caneffectivelytakeadvantage of20-bitsources. •24bitThisbitdepthisrapidlybecomingthestandardforprofessionalaudiorecordingbecause itprovidesmoresonicdetailthan16bit,meaningyoucanusemanymoreeffectsandlayerswithoutintroducingerrors.Fewdeliverycodecsnowsupport24bit,mostprominently MicrosoftWMAProfessionaldoes.Thedifferencebetween16bitand24bitwon’tbeaudible onatypicalhomecomputerspeakersystem,butitcouldbegintomatteraspeopleintegrate personalcomputersintohometheaters. Channels Mostaudiofromcomputersiseithermonowithasinglechannelorstereowithtwochannels. Lowbitratesgenerallyusemonobecauseitrequiresfewerbits.Theindustryisevolvingtouse multichannel(5.1and7.1)audiosupportaswell.Multichannelsupportisincludedtodaywith MicrosoftWMA9ProandRealNetworksRealAudio10.Andofcourse,DVDhasalwayssupportedmultichannelthroughDolbyDigital. Perceptualaudiocompression Reducingthesamplerateandnumberofchannelscanreducethedatarate;however,decent compressionmustgowellbeyondthat.Mostmoderncodecsuseperceptualencodingtechniques,thatis,aninternalmodelofthehumanauditorysystemdeterminestheimportantparts ofanaudiosourceandspendstheavailablebitsonthoseparts.Atlowdatarates,theaudiocan stillsoundquitealteredfromthesource.Thenumberofbitsrequiredfor“goodenough”qualityhasbeendroppingprecipitouslyinrecentyears.
Compressionefficiency So,howdoessomeonecomparecodecs?Thefundamentalmeasurementiscompressionefficiency,whichisdefinedbyhowmanybitsarerequiredtoreachaparticularqualitylevel.When improvingcompressionefficiency,youcanchoosetolowerthedataratewhilekeepingthe qualitythesame,increasethequalitywhilekeepingthedataratethesame,orpickapointin between. Youcan’tmeasurecompressionefficiencywithasinglenumber.Relativeperformancevariesgreatlyanddependsonthesourceandthedatarate.Typically,thehigherthedatarate,the smallerthequalitydifferences.It’swithaggressivedataratesanddifficultcontentthatcompressionefficiencymakesadifference.
Authoringvideoforfuturecompression Onekeytogreatcompressioniscreatingcontentthatcompresseswell.Sometimesitisn’tpossibletocreatethistypeofcontent—legacycontentislegacycontent.Butwhencreatingcontent forcompression,thereareavarietyoftechniquesthatyoucanapplytoproducebetterresults. Youcanapplythesetechniquesduringpreproduction,production,orpost-production. Preproduction Inpreproduction,youplanoutthevariouselementsofaproject.It’sbesttointroducetheidea ofcompressionearlyinaproject,soallmembersoftheteamcanconsidertheimplications. CompressionPrimer
9
Production Duringproduction,youcanmakeadjustmentstothevideo,suchaschangingtheshutterspeed, cameramotion,andbackground,andyoucanmakethevideoaseasytocompressaspossible. •InterlacedversusprogressivescanForcontentshotwithavideocamera,onefundamental decisioniswhethertouseinterlacedorprogressivescanvideo.Historically,videowasalways interlaced.Inaninterlacedframe,theoddandevenlines,calledfields,containimagesthat arecapturedhalftheframedurationapart.Eachvideoframeismadeupoftwofields. Whydofieldsexistinvideo?Thefirsttelevisionsetsusedasingleelectronguntoshoota steadybeamofelectronsattheinsidesurfaceofthepicturetube.Theseelectronswouldexcite thephosphorousmaterialthatcoatedtheinsideofthepicturetubeandmakeitglow,giving usanimage.Thegunwouldmovefromonesideofthescreentoanother,illuminatinga singlelineknownasascanline.Itwouldthendropdownalineandmoveacrossoncemore. Itwoulddothisforthe486linesthatcomprisedtheimage.Theproblemwasthatbythetime thegunwouldgetabouthalfwaydownthescreen,thelinesatthetopwerealreadybeginning tofadeout. Thesolutionwastosplitthe486linesintotwofieldscalledoddandeven(consistingofodd numberedlinesandevennumberedlines).Nowtheelectronguncouldskipeveryotherline anddrawacompletefieldfromtoptobottom.Itwouldthenstartfromthetopandfillinthe missinglines.Theresultwasthattheeyewouldseeacompleteimagebecauseonlyhalfwould befadingawayatanyonetime.This“interlacing”oftheoddandevenlinesbecameknownas interlacescanorfieldscanmode. Motioncamerasandvideotaperecorderswerebuilttorecordvideointhesameway.As aresult,thesecondfieldshowsanimagethatisexactlyone-sixtiethofasecondlaterin timeinNTSCandone-fiftiethofasecondlaterinPAL(NTSC=30framespersecond, eachframe=twofields,eachfield=1/60thofasecond;PAL=25framespeersecond,each frame=twofields,eachfield=1/50thofasecond).Ifmotionoccursinthevideo,thenthe imageinonefieldwillbeslightlyofffromtheimageintheother.Youcanseethiseffectif youpauseyourVCRathome.ManyVCRswillpauseonaframeandcontinuetoalternate betweenthetwofieldsthatcomposetheframe.Thiscausesajitteringeffectcalledfieldjitter. Thisdifferencebetweenfieldsaddscomplexitytothecompressionprocess.Agoodvideo compressiontoolmustreadandunderstandfields,compressthemindependently,andallow forthemtobeplayedbackasfieldsinthecompressedformat.Compressionforthewebgenerallydoesnotshowfieldsbecausecomputermonitorsarenotfieldbased.Advancedtechnology forcomputersallowstheentirescreentobedrawninasinglepass,usuallywithmorethan oneelectrongunfortube-baseddisplays.Flatpanelmonitorsdonotuseelectronguns,and theygeneratetheentirescreeninstantly.Thisprocessisknownasprogressivescan. Interlacevideodoesnotlookgoodonprogressivescanmonitors.Compressiontechniques forthewebusuallychangethevideofrominterlacescantoprogressivescan.Themostbasic methodforthischangeistothrowawayonefieldandduplicatetheothertocreatethefull frame.Thisprocessreducestheamountofdatayoustartwithby50%,whichcanadversely affectthefinalquality.Themorecomplexmethodisforthecompressortoreadbothfields andinterpolate(blend)themintoasingleframebychangingthepixelstosmoothoutthe timingdifferencebetweenthefields.Thismorecomplexmethodallowsyoutostilluseallthe originaldatafromthevideoandproducehigherqualitystreamingmedia. CompressionPrimer
10
•CameramotionTheamountandtypeofcameramotionhasahugeeffectonthecompressibilityofcontent.Cameramotionchangeseverypixelofeveryframe.Lackofcameramotion isthesimplest,ofcourse.Butmoderncodecscanencodecameramotion,likedollies,quite well.Tiltsandpansaremoredifficult.Dependingonthecodec,rotatingthecamera(aDutch) canbetrivialorextremelycostlyincompressionefficiency.Themostdifficultmotionforany codecishand-heldcameramotionwithrandomjostling. Forcompression,it’smucheasiertohandlechangesofviewbyeditingratherthancamera motion,especiallyatlowerdatarates. •ShutterspeedThisspeedcontrolshowlongtheapertureisopeninthecamera,andhence, howlonglighthitsthefilmortheCCD.Slowershutterspeedsletthroughmorelight,and hencelessgrain,whichhelpscompression.Slowershutterspeedsalsocausemovingpartsof theimagetobecomeblurry,whichmakesthemeasiertocompress. Thedefaultshutterspeedformostcamerasishalfthatoftheframerate:1/60ofasecond forNTSC,1/50forPAL,and1/48forfilm.Thedefaultsprovidegoodresultsformostvideo meantforcompression.Theexceptiontothosedefaultsisactionandsportsvideography, wherevideographersavoidmotionblurtomakeslow-motionimagescrispandclear.Beaware oftheseexceptionsincompressiontests. •BackgroundsAdifficultmotionforcodecsisfoliagerustlinginthebreeze.Foliageisgreen, whichmakesupthemajorityoflumaandthereforegetsallocatedalotofbitsinthecompression.Leaveshavehard,irregularlyshapededges,anddetailsthatrequirealotofbitstoencode well.Additionally,themotionoffoliageinthebreezeislargelyrandom,withleavesconstantly overlappingandrevealing,allmotionsthatareverydifficultformotionestimationtohandle. •DepthoffieldAusefulandsubtletechniqueforcontrollingthecomplexityofimagesisdepth offield.Bymanagingthedepthoffield,youcankeepunimportantobjectsinthebackground orcloseforegroundoutoffocuswhileclearlyshowingtheactualsubjectoftheshot.Depthof fieldisverycommonincinematographyandphotography,soitlooksnaturaltotheaudience. Ifthereisnotenoughspatialseparationamongobjects,backingupthecameraandusinga telephotolensnarrowstheregioninfocus. Post-production Post-productiontechniquescanhaveasmucheffectoncompressibilityasproductiontechniques.Becausepost-productiontechniquesoccurlaterintheprocess,itisoftenpossibleto adjustthembasedontheresultsoftestcompressions,makingfine-tuningmucheasier. •StaticversusmovingimagesAsinproduction,superfluousmovingimagesaren’tappropriate forcontentthatyouplantoaggressivelycompress.Theyarenotthatimportantofanissuefor DVD,buttheyareforwebandCD-ROM. •MotionblurInthesamewaythatareal-worldshutterspeedintroducesmotionblurthathelps compression,youcanusethevirtualshutterinrenderingapplications.Foreffectsthatsupportmotionblur,renderthemwithashutterspeedthatmatchesthatofthesource.Thisspeed mightbeexpressedasaduration,or,asinAfterEffects,astheangleofavirtualshutter.The defaultis180°,whichcorrespondstoashutterspeedhalfthatoftheframerate. •Anti-aliasingThisrenderingtechniquesoftenstheedgesofrenderedelements,lettingapixel attheedgeofanareabeanintermediatevalue.Smoothingouttransitionsamongpartsofthe imageimprovescompressibilityandappearance. CompressionPrimer
11
Anti-aliasingmaybeitsowncontrol,oritmaybepartofanoverallgroupofrenderingsettings.Forexample,inAfterEffects,anti-aliasingisautomaticallyturnedonwhenencoding inBestmode. Anti-aliasing ThesesamplesshowanAdobe Illustrator®file,exportedtoa Photoshopfile(PSD)aliasedand anti-aliased,andthenconverted toJPEGinAdobeImageReady®. Thefileswereconvertedtothe samesize,and,asyoucansee,the anti-aliasedimagehassignificantly fewerartifacts.
•ProgressiverenderingWhenworkingwithinterlacedsourcevideo,itmaybeappropriateto rendermotiongraphicsasprogressivescanwhenmakingthecompressionmaster.Byrenderingouttheprojectinprogressivescanmode,youcandeinterlacetheinterlacedsource,but thegraphicalelementsremainaperfectprogressive.
Capturingvideo:choosingformatsandconnections CapturingvideoishowcontentgetsfromanexternalsourcelikeaVTRorcamcorderintothe computer.Thetypeofvideo,orformat,andtoalesserextenttheconnectiontypeyouselectto capturecontent,candramaticallyaffectthequalityofthevideoonthecomputer.It’salways desirabletostartwiththehighestpossiblequalityvideoandaudiosignal.Inalmosteverycase, compressiondoesn’tmakevideolookbetterthantheoriginalsource.Thehigherthequalityof thesourcematerialused,thehigherthequalityofthefinalcompressionresults.Theinverseis alsotrue,soitishelpfultobuildabasicunderstandingofthevideoandaudioformatsavailable andhowtheycompareinquality. Today’seditingsoftware,suchasAdobePremierePro,andmanycompressionsoftwaretools, cancapturecontentinavarietyofways.Videocanbecapturedfromanalogordigitalsources. Bothhaveavarietyofdifferentvideoandaudioformatsavailableandvariousphysicalconnectiontypesthatcanbeused.Inmostcases,you’llneedtoinstallavideocapturecardwiththe properphysicalconnectorsinyourcomputertoperformthecaptures. Tounderstandthevideoformats,it’sfirstnecessarytounderstandthevideosignalcomponents.Inthebeginningofvideo,wedealtonlywithbrightness,orluminance(luma)signals. Thevariationsfromverylowbrightnessallthewaytocompletebrightnessgaveusblackand CompressionPrimer
12
whitetelevision.Colorwasaddedbygeneratingtwochannelsofcolor,orchrominance(chroma)valuesforthesignal.Toaccommodatethemillionsofblackandwhitetelevisionsetsstill inuse,amethodforaddingcolorwasinventedthatallowedablackandwhitesettoignorethe colorsandstillshowtheluminance,orblackandwhite,picture.Sincebroadcasttelevisionis transmittedoverantennas,theluminanceandtwocolorchannelsaresenttogetherasasingle signal.Thevariousvideoformatsusedtodaywerecreatedusingthistechnology. Alistofthecommonvideosignalformatsfollows,alongwiththepopulartypesofcablesand connectorsfortransmittingthem. •AnalogformatsAnalogvideousesfluctuatingvoltageandfrequencysignalstotransmitimage data.Itrangesgreatlyinqualitybutisinherentlysusceptibletovisualinterferencefromelectronicnoise,likepowerlines,andsuffersattenuation,orthelossofsignalpowerandquality overlongcableruns(usually300metersormore).Equipmentthatsupportsanalogsignalsis generallymoreaffordableandanalogvideoformatsarestillthemostcommonlyusedbecause ofthelong-termuseoflegacyequipmentthatisstillactivetoday. Becausecomputersonlyusedigitaldata,theanalogsourcemustbeconvertedtoadigital copytobecaptured.Whenitissentbacktotape,itisconvertedbacktoananalogsignal.This conversion,knownasencodinganddecoding,canleadtominorerrors(quantizationerrors) beingintroducedbecauseoftheimpreciserelationshipbetweenanaloganddigitalsignals.By usingtherightformat,goodequipment,cables,andconnections,thesequantizationerrors canbeminimized.
AnalogtoDVconverters Thereareboxesthatcanperforma liveconversionfromanalogvideo formatstoDV25forcapture.They usuallyoffercomposite,S-Video, andunbalancedanalogaudio conversiontotheDVformatfor storageonthecomputer.The 25-MbpsdatarateofDVissufficientforcontentthatcamcorders produce,butitcanbetroublesomeforconvertingsourceswith alotofanalognoiseonlower-end versionsoftheconverters.
•CompositeAcompositevideosignalcarriestheluminanceandthechrominancechannelsin asinglesignal.Thebiggestproblemwithcompositevideoisthatlumainformationcanleak intochroma,andviceversa.Thisleakagecanleadtonoise,knownaschromacrawl,thatcan beamplifiedbythevideocaptureprocessandreducetheoverallquality.Compositevideo isgenerallyunderstoodtobethelowestqualityvideosignalthatyoucanuseandismore appropriateforvideodelivery(broadcast)thanasasourceforcontentcreation(videoediting, DVDauthoring,orencodingfortheweb).CommonsourcesofcompositevideoareVHS(1/2 inchtape)VCRsandcamcorders,broadcasttelevisionsignals,andolderU-Matic3/4-inch professionalVTRs. TheconnectorscommontocompositevideoareRCAorCinchintheconsumerspaceand BayonetFittingConnector(BNC),atwist-lockingconnectorcommontoprofessionaland broadcastvideoequipment.AsthequalityoftheRCAorBNCcablethatisusedincreases,the noiseandattenuationdecreases. •S-VideoTheintroductionoftheS-Videoformatwasamajoradvanceinqualityforconsumer andprofessionalvideoeditors.S-Videosplitsthelumaandchromachannelsintotwoseparatewirepairs,whicheliminatesgenerallyhalfofthecompositenoiseartifacts.Thetwochromachannelsarestillcombinedandstillinterferewitheachother,leavingsomenoiseinthe signal.Manyprofessionalandconsumer-gradevideoequipmentmanufacturers,including Hi8camcordersandS-VHSVCRs,provideanS-Videoconnector.Whilenolongerconsidered trueprofessionalgrade,itisabigimprovementfromcompositeandcanbeconsideredagood videocaptureminimumstandardforforeditingandcompression. S-Video,orY/C(YforLumaandCforchroma)videosignalsmostlyuseaspecificfour-pin connectoronS-Videocables.Thesecablesareintendedforshortdistances(usually100feetor less).SometypesofprofessionalandbroadcastequipmentusetwodiscreetBNCcables,one CompressionPrimer
13
forlumaandoneforchroma,tocarryS-Videosignals.Thissetupprovidesaconnectionthat canberunfartherandthatcanbelockedintoplacetopreventthecablefromfallingoutand losingthesignal. •ComponentanalogComponentanalog,alsoknownasYUV(Yforluminance,Uforonechromachannel,andVfortheotherchromachannel)wastheprofessionalandbroadcaststandard formanyyearsanditisstillwidelyusedtoday.Withcomponentanalog,theluminancesignal andthetwocolorsignalsarealltransmittedovertheirowndedicatedcables.Becauseallthree componentsorchannelsofthevideosignalaretransmittedindependently,thequalityofthe signalisquitehigh.Noiseisverylowandthecolorsinthevideoarericherandmoreprecise.In broadcastandprofessionalenvironments,componentanaloghasmostlyyieldedtodigitalvideo formats.Componentanaloghasbecomeverypopularintheconsumermarket,though,asthe preferredformatforconnectinghomeDVDplayerstonewtelevisionsets,owingtothepristine natureofthesignalcomparedtoS-VideoandCompositeformats. Inprofessionalenvironments,thecomponentanalogsignalswerecarriedbythreeindividual BNCcablesbecauseofthelongrunandlockingnatureofthisconnection.Inthenewhome DVDplayers,itiscommontoseeRCAorCinchconnectorsusedthatarecolorcodedred, green,andbluetomakeiteasytoconnecttheDVDplayercorrectly. •UnbalancedaudioAnalogaudioisbasicallyasinglevoltageandfrequency-basedanalogsignal, nomatterwhattheconnectortypeis.Theconnectortypecangreatlyaffectthequalityand generallydeterminestheuseoftheaudio Therearethreebasickindsofunbalancedaudioconnectors.Themostfamiliartoconsumers istraditionalunbalancedaudiothatusesRCAorCinchjacks(normallyredforrightandwhite orblackforleft).TheRCAconnectorsuseasingletwo-wireconnectionfortheleftandright channels,whichrequireseitherasingleRCAcableforeachchannelorasingle“stereopair” cable.TheleftandrightchannelcablesaremanufacturedasasinglecablewithtwoRCAconnectorsoneachend. Othersingle-cableunbalancedconnectorsexist.TheOne-QuarterInchconnectoriscommon tohigh-endheadphonesandisstandardonmosthomestereoequipment.Similarbutsmalleris theOne-EighthInchconnectorthatisstandardforportableaudiodevicesandcomputersound cards.Becausethesearenotamplifiedconnections,theyarealsocalledlinelevelsignals.In thecorrectcircumstances,unbalancedaudiocanworkwell,butitissusceptibletointerference fromotherelectronicsources’groundedoutletloopsandisn’tappropriateformanyprofessionalapplications. •BalancedaudioTheprofessionalstandardforanalogisbalancedaudio.Unlikethetwowiresof unbalancedaudio,balancedaudiousesthreewires,oneforthepositivesignal,oneforthenegativesignal,andoneforanisolatedground.Usingthreewiresdramaticallyimprovesresistance tointerferenceandgroundloopnoise.BalancedaudionormallyusestherelativelylargeXLR, orthree-pin,lockingconnector.Onceagain,longercablerunsandalockingconnectorform thebasicstandardforaprofessionalconnection. Digitalformats Digitalvideorecordstheoriginalvideosignalontapeusingdigitaldatasimilartothatusedby computers.Allbrightnessandcolordataisstoredinthisveryaccuratecomputer-stylemethod andassuchsuffersnoproblemofinterferenceornoisebetweenthechannelsofthevideosignal. Digitalsignalsarethereforecleanerandcrisperthananalogsources.Thedigitaldataformat CompressionPrimer
14
allowsdigitalvideotobe“copied”fromtapetoacomputerharddiskwithouttheconversion processthatanalogvideomustgothroughwhenitiscaptured. Manydigitalformatshaveemergedinthevideoindustry.Manyoftheseformatsarerelatedto compressionandnotacquisitionorfilmingwithadigitalcamera.Thissectioncoversonlythe mostpopularacquisitionformatsofdigitalvideo. •DV25(DV)Thisaffordabledigitalvideoformatismostcommonlyknownbythephysicalconnectionstandardituses,IEEE-1394orFireWire.Itisactuallyadigitalvideoformatthatuses onlyafractionofthedatarateandspeedavailableintheIEEE-1394connectionstandard.This formatrevolutionizedthevideoeditingindustry,becomingthefastestgrowingformatfornew editorsandthedefactostandardfornews,owingtothesmallsizeandrelativelylowcostof theDVcamcorders.Thevideoformatiscompressed5:1duringacquisitionorrecordingon thecamcordersinordertoreducethedatarateofthesignalandisonlyslightlyhigherquality thantheS-Videoanalogformat.HigherendDVcamcorderscanproduceaDVsignalthatis almostasgoodascomponentanalogvideoatthesameDVdataratebecauseofbetterrecording technology. TheDVformatisdigital.Itincludesaseriesofcomputer-style1sand0sandnoanalogsignals. Thisformatenablesthevideodatatobe“copied”fromtheDVtapedirectlytoacomputer equippedwithaFireWireconnection.Thedataonthecomputerisexactlythesamedataason thetape,sotheresultisaperfectcopy.Manynonlinearvideoeditors,likePremierePro,can readandeditthisformatnatively.Thefinishedvideoisvirtuallythesameastheoriginalsource footagewhenitisfinal.Fewtonoprocessingerrorsareintroduced. ThephysicalconnectorfortheDVformatisbasedonanIEEEstandardscommitteedesign knownasIEEE-1394(alsoknownasFireWireandi-Link).Asadigitalformat,boththeaudio andthevideosignalscanbecarriedonasingle,inexpensiveFireWireor1394cable.Inaddition tovideoandaudiosignals,thiscablealsocarriesdevicecontrolsignals,allowingthecomputer tocontroltheDVcamcorderautomatically.Originally,onlyDV25wasusedonFireWire,a25 megabit(Mbit)datarateformat.Increasingly,otherdigitalformatsarebeingsupported,like DV50(50MbitDVCProandDVCam)intheprofessionalandbroadcastmarkets.Newer100 MbitformatslikeDVCProHDarebecomingpopularashigh-definitiondigitalvideoformats. AdobePremiereProsupportscapturingDV25andDV50overanystandardFireWireportcommontomostnewcomputers.InexpensiveFireWireadd-incardscanbepurchasedandaddedto mostcomputersandlaptopcomputers.Bothfour-pinandsix-pinDVconnectorsareavailable, andtheyarecompatiblewitheachother.DVcamcordersusuallyonlyfeaturethefour-pin connectorasitisasmallerconnectorandonlythefourpinsareneededfordatatransmission. Theextratwopinsonthesix-pinconnectorareforpowercommonlyused,forexample,by FireWireharddisks. •SDI(SerialDigitalInterface)SDIisthehigh-endprofessionalformatfordigitalsignals.The SDIformat,technicallyknownasCCIR-601or“601”,issuperiorinqualitytocomponent analogvideoandhasbecomethestandardinprofessionalandbroadcasttelevisionproduction environments.Becauseitisdigitalanduncompressed,theformatcanbeeditedandcopied manytimeswithnodetectablelossofquality.SDIwasoriginallymeantforstandarddefinition, butahigh-definitionversion,HD-SDI,isgrowinginpopularityasHDbecomesmorecommon.(PleaseseetheAdobeHDPrimer.)SDIistypicallyonlysupportedinhigh-endgearand canbequiteexpensive,especiallyforSDIvideomonitors. Asadigitalformat,thevideo,andsometimestheaudio,canbecarriedinasingleBNCcable.
CompressionPrimer
15
•DigitalaudioTherearemanydifferentdigitalaudioformats.Consumergradedigitalaudiois carriedonelectronic(suchasSPDIF)oroptical(suchassquareTOSlinkorroundMiniplug) connectioncables.DVcarriesanembeddeddigitalaudiosignalwiththedigitalvideosignal. ThemostcommonprofessionalgradedigitalaudioformatisAudioEngineeringSociety/EuropeanBroadcastingUnion(AES/EBU)digitalaudioformat.AstereochannelofAES/EBUcan betransmittedoversingleBNCorsingleXLRconnectioncables.SDIvideoequipmentcan sometimescarryembeddedAES/EBUdigitalaudio,butitismorecommonforaseparateAES/ EBUorbalancedaudiostereopairtobeusedwiththeSDIvideosignal.
Choosingtherightcapturecodec Whencapturingcontent,youmustchooseanappropriatecodec.Thechoicedependsonthe capturehardwareyou’reusing,theformatyou’recapturingfrom,andthediscstorageyouneed. Therearethreebasictypesofcodecstochoosefrom:DV,MotionJPEG,anduncompressed. UnderstandingDVcodecs TheDV25formatisidealwhencapturingfromaDV25deck.OvertheFireWireconnector,you canuseDV25tocopythenativebitsfromthetapeontoaharddrive,makingaperfectcopy.If youuseadifferentformatatahigherdatarate,theresultingvideowillstillbeslightlylossy. UsingaDVbridgetoconvertanalogsourcetoDV25maywork,butthequalitylessens.Thedata rateofDV25isn’tquiteenoughforoptimalencodingfromsourcewithanalognoise.Also,the 4:1:1colorspacealsoentailsalossinquality. UnderstandingMotionJPEGcodecs MotionJPEGhasbeentheleadingformatforhigh-endvideo-editingsystemsforsometime. Theproprietarycodecssupportedbymanyvendorsofcapturecards,liketheTargaandPinnacle codecs,arevariantsofMotionJPEGandshareitsproperties. MotionJPEGis4:2:2,andmostimplementationsallowyoutospecifyadatarateorqualitylevel. SomeimplementationscanevendoamathematicallylosslessMotionJPEG.Typically,datarates of50Mbpsorgreaterareconsideredbroadcastquality. Understandinguncompressedcodecs Moreandmorecardsaresupportingtrue4:2:2uncompressedvideo.Thedataratesarelarge, andthequalityisn’tanybetterthanalosslesscompression.Onesignificantadvantageofsome uncompressedcodecsissupportfor10-bit-per-channelcaptures,whichcanhelpthequalityfrom analogandespeciallySDIsources.High-endtools,likeAfterEffects6Professional,areableto processvideoinmorethan8bitperchannel,improvingthequality.Somehardwarevendorsalso includesupportfor10-bitrenderinginAdobePremierePro.Becauseuncompressedcodecshave suchhighdatarates,youshoulduseafastdrivesystem,suchasRAID. Note:Don’tconfuseuncompressed4:2:2withuncompressedRGBcodecs,oftencalledNone.
Exportingvideo Capturingfromtapeisrequiredformanyprojects,butforsomeprojects,allcontentiscreated electronically.Inotherprojects,alotofcreativeworkisdoneineditingandcompositingonthe computer.Inthosecases,goingbackouttotapeisanunneededdistraction.Manytools,like AfterEffectsandAdobePremierePro,canexporttoacompressedfilefromthetimeline,which workswellforasinglefile.However,iffeaturesinotherencodingtoolsarerequired,likevolume encodingtomultipleoutputformats,itisusefultoexportanintermediatefilefromthetimeline andusethatforfurtherprocessing. CompressionPrimer
16
Exportingasfile Afileexportedforlaterprocessingiscalledanintermediatefile.Thegoalofcreatinganintermediatefileistoprovidehighqualityinthemostusefulformatwithoutintroducinganycompressionartifacts. Choosingwhethertopreprocessortoavoidrendering Thefirstquestionthatyoushouldaskiswhentoapplypreprocessing(describedinthenext section):duringtherenderingphaseorlater.Preprocessingduringrenderinggenerallyresults inasmallerfilebutaddsmorerenderingtime.Italsomeansyoucan’tuseanencodingtoolfor specialoperationsnotavailableintheexportingapplication,likeinversetelecine. Generally,whenyouavoidrendering,youshouldusethesamecodecandfileformatthatyou usedinthesourcevideo.Ifyoudon’tpreprocess,youdon’tneedtouncompressandthenrecompressunmodifiedframes—instead,youcopythemfromthesourceintotheoutput.Different toolssupportthisprocessindifficultways—inAdobePremierePro,youdothisbyturning offtheRecompressoptionintheVideopaneoftheExportMovieSettingsdialogbox.Forthis processtowork,thevideomusttrulybeunchangedwiththesameframerate,framesize,pixel aspectratio,andsoon.Thesimplestwaytoensurethatnochangesweremadetothevideoisto usethesameprojectpresetforexportthatwasusedforimport,whichisthedefaultbehaviorin AdobePremierePro. Thereisoneexceptiontoexportingwiththesourcecodec:whenthesourceisDV25andcontainsalotofmotiongraphicsorcompositing.Becausethesesyntheticelementshavealotofprecisecolor,exportingtoa4:2:2codec,likeMotionJPEG,insteadofNTSCDV25’s4:1:1provides twicethecolordetail. Whenpreprocessing,choosethehighestframerateandlargestframesizethatyouwilluse.If targetingwebcodecs,useasquarepixelaspectratio. Choosingafileformatforrendering Youcanchoosefromavarietyoffileformatsforrendering.ThemostcommonareQuickTime andAVI,bothoffergood-qualityintermediatecodecs.YoucanalsouseMPEG-2athighdata rates.ModerntoolslikeAfterEffects6andAdobePremiereProcanuseWindowsMedia9for exporting.Thekeyistomakesurethattheencodingtoolsupportsthefileformat. Choosingacodecforexporting Whenexportinganintermediatefile,pickacodecandadataratethatdoesn’tintroduceany compressionartifacts.Whenyouarenotpreprocessing,it’stypicaltousethesourcecodecor MotionJPEG.WhenyouuseMotionJPEG,useitinsinglefieldwhenyouexportasprogressive scanorinterlacedwhenyouexportasinterlaced. ForAVIfilesonWindows,theHuffyuvcodecisquitepopulartouse.
Understandingpreprocessing Preprocessingisthemiddlestepofvideocompressionandinvolvestransformingthedecoded frameofthesourcevideointotheoptimizedframegiventothecodec.Thegoalofpreprocessing istotransformthevideointothefinalformat. Whypreprocessingmatters Preprocessingisoneofthesubtlerstepsofcompression,butitisoftenthemosttimeconsuming andthemostdifficult.It’salsoveryimportantforquality,andgettingitrightcandramatically CompressionPrimer
17
improvethequalityofthefinalvideo.Awellpreprocessedvideocanlookbetterthanthesame sourcepoorlypreprocessed,butcanbeencodedattwicethedatarate. Preprocessingiscriticalforwebvideo,butgenerallyitisnotneededwhengoingtovideoformats likeMPEG-2forDVDorSVCD.Becausethoseformatsareplayedbackasvideo,insteadofona computerscreen,youcanleavethemasis. Also,youcancreaterenderedgraphicsnativelyforcomputerplaybackwithoutanypreprocessing. Deinterlacingvideo Themostbasicandcriticalformofpreprocessingforthewebisdeinterlacing.Mostvideois producedandeditedasinterlaced(although,anincreasingamountisdoneasprogressivescan). Butalmostallwebvideoisencodedasprogressivescan.Ifthesourceframeofvideoisleftwith interlacedlinesintact,theoutputshowsthestackedlines.Thelineslookbad,butworse,those lineshavesharpedgesandaredifficulttoencode.So,atthesamebitrate,deinterlacedvideo showsfewerartifactsthaninterlacedvideo.
Differencesbetweeninterlaced anddeinterlacedvideo Thesamevideoframe,shown priortocompressionandafter compression,asbothprogressive andinterlaced.Notethatthereare morecompressionartifactsinthe interlacedversion,eventhoughthe filesizeisthesame.
Note:MPEG-2encodedforDVDorSVCDdon’tneedtobe,andshouldn’tbe,deinterlaced. MPEG-2canencodeframesinaspecificinterlacedmode. Workinginprogressivemodewhenauthoringforprogressiveoutputcangiveyousubstantially betterresultswhenexportingfromatoollikeAfterEffectsandAdobePremiere,whereyoucan addafairamountofgraphicsorothersyntheticeffectsontopofthevideo.Thetoolsautomaticallydeinterlaceinterlacedsourceswhiletheydoalloftheadditionalprocessinginprogressive mode,providinghigherqualitythanifyoudeinterlaceeverythingduringexport. Understandingtelecineandinversetelecine Aspecialcaseofprogressivescanisfilmsourceandfilm-like24pproduction.Traditionalmotion picturefilmrunsatexactly24framespersecond(fps)progressivescan,whichdoesn’tconvertto the59.94fpsofNTSCorthe50fpsofPAL. ConvertingfromfilmtoPALiseasy.Thevideoisspedup4%to25fpsandconvertedintoprogressivePAL. CompressionPrimer
18
NTSCisalittlemorecomplextoperform.Thefilmisfirstsloweddownto23.976fps,andthen itisconvertedtothe59.94fpsbyusing3:2pulldown.Thefirstframeoffilmbecomesthree fieldsofvideo,andthenextframebecomestwofieldsofvideo,andthenextbecomesthree fields,andsoon.Thisprocessresultsintwooutoffiveframeshavingfieldsthatcomefromdifferentsourceframes. Fortunately,24pvideoisevolvingintoaproductionstandardofitsown,soeditingtoolscan increasinglyjustauthorin24pandthenconvertfromthatuniversalmastertoPAL,NTSC,film, orwebformatsasappropriate.Whenpossible,itisbesttoconvertto24ponimportandthendo alltheworkontheprojectin24pmode.
Cropping Croppingisexcludingareasofthesourceframefrominclusionintheoutputframe.Content composedforvideonormallyconfinescriticalelementstowhat’scalledsafeareas.Thesafeareas excludetheedgesofthescreen,whichmaybecutoffordistortedonsometelevisions(especially olderones). Insometools,youcancropanimagebyusingaspecificfilter.Inothers,likeAfterEffects,the easiestwaytocropanimageistoscalethevideoupsotheunwantededgesarenolongerpart oftheframe.Ifanasymmetricscaleisdesired,youcanmovetheanchorpointofthevideoas needed. Onespecialcaseofscalingisgoingfrom720pixelswidesourceto352pixelswideoutputfor VideoCD.Thespecifiedmethodforthisscalingistocropeightpixelsfromtheleftandrightof thesource,leavinga704pixelwideframethatyoucanreducebyexactly50%to352pixelswide. Anotherspecialcaseisgoingbetween486lineand480linesourcesinNTSC.MotionJPEG commonlyuses720x486andMPEG-2commonlyuses720x480.Thedifferentlinecountisn’t duetodifferentscalings,butitisduetosixmorelinesofthevideosignalcapturedinthe486 linemode.Whenconvertingfrom486lineto480line(forexample,inDVDauthoring),you’ll needtocropsixlines.Generallyfourlinesoffofthetopandtwolinesoffofthebottomworks well.Conversely,ifyou’regoingfrom480lineto486line,you’llneedtoaddsixlines(againfour linesonthetopandtwolinesonthebottomaregoodchoices).Doingoddnumberscanswitch fieldorder,resultinginsubstantialproblems.
Safeareas Theinnerboundryisthetitle-safe area,andtheouterboundryisthe action-safearea.
CompressionPrimer
19
Scaling Scalingisresizingthecroppedsourcerectangletotheproperoutputframe,forexample,going froma720x480sourceframetoa320x240outputframeforwebvideo. Scalinguponeitheraxisforcesthetooltomakeupdatathat’snotinthesource.It’salways preferabletoscaledownonbothaxesifpossible. Aspectratiocorrection Oneimportantelementofscalingisaspectratiocorrection.Mostproductionformats,likeDV, arenonsquarepixel.Forexample,DVinNTSCis720x480,which,bylookingatpixelsalone, wouldimplyanaspectratioof3:2.However,DVisn’tever3:2;instead,it’seither4:3or16:9, dependingonhowitwasproduced.In4:3mode,thepixelsaremorenarrowthansquare,andin 16:9mode,they’remorewidethansquare.NonsquarepixelsarealsousedforMPEG-2forDVD andMPEG-1forSVCDandwithdifferentshapesforMPEG-2forSVCD. Conversely,mostwebvideoformatsusesquarepixels,whichmakesiteasiertodothemath.For example,320x240is4:3insquarepixels. Thekeytogettingaspectratiocorrectionrightwhengoingtosquarepixelsourcesfromnonsquarepixelsourcesistomakesurethattheoutputframesizematchesthesourceaspectratio. So,ifyouusea4:3source,a4:3framesizesuchas160x120,320x240,400x300,512x384,or 640x480areallgoodchoices,evenifthesourceframesizeis720x480,720x486, 640x480,or352x480. Theimportanceofaspectratios Thisgraphicshowsa4:3anda16:9 720x480image;eachtransformed intoa4:3anda16:9output.Getting theoutputaspectratiocorrectis criticallyimportant.
CompressionPrimer
20
Noisereduction Noisereductionencompassesavarietyoftechniquesusedtoremovenoise,especiallygrain,from theimage,makingiteasiertocompress.Verysimplenoisereductionalgorithmsarejustblurs— theycanhidegrainbutcanmaketheimagequitesoftaswell.ThecommonlyavailableMedian filterisagoodblurfornoisereduction.Moreadvancedalgorithmstrytobluronlythepartsofthe imagewithgrainandmaytakeadvantageofthedifferencesamongframes. Onthehighend,therearetoolsthatcanperformautomaticormanuallyassistedscratchremoval andotherimprovementsfordegradedsource.Normallythesearestand-alonetoolsorplug-insto avideotoolandneedtobeusedearlierintheprocess. Youdon’talwaysneedtoapplynoisereduction.Verycleansourceisn’thelpedbynoisereduction, andnoisereductionmayhurtthesourceaudio.Typically,youshoulduseonlytheminimumnoise reductionrequiredtosuppresspoorqualityinthesource.
Imageprocessing ImageadjustmentistheprocessofusingPhotoshop-likecontrolstochangetheoverallimage. Becauseofdifferentcolorspacesusedbydifferentcodecs,imageadjustmentusedtoberequired formostprojects.Today,forthemostpart,modernformatsandtoolsautomaticallytakecareof imageadjustmentsoitismainlydonetoimprovethesuitabilityofthecontentforcompression andisn’trequiredformostprojects. Lumarangeexpansion Inthepast,amajorissueinvideocompressionwasmakingsurethatblackwaspureblackand whitewaspurewhite.Inessence,sometools,formats,andcodecsconsideredblacktobe0and whitetobe255,butothersusedtheITUstandardofblackas16andwhiteas235.Forthemost part,moderntoolsautomaticallykeeptheseconsistent.Butifblacksandwhitesappeareither crushedorfaded,theremightbealumarangemismatchduringtheauthoringprocess.Normally allRGBcodecsusethe0-255range,Y'CbCrcodecsusethe16-235range,andvideotoolsautomaticallyconvertfromY'CbCrorRGBtotheother.BewareofcodecsthatusestudioRGB,which alsousesthe16-235range(youmayneedtoaddadditionalcontrastwhenconvertingtoadelivery codecfromthesecodecs). Blacklevels Anothergoalofcontrollinglumaismakingblackandwhiteinthesourcemathematicallyblack andwhiteintheoutput,respectively.Forelementslikedigitallyrenderedtitlecards,achievingthis goalshouldhappenautomatically.Butvideocapturedfromanalogtapealwayshasnoise,which randomizesthelumavaluesofpixelsandleavessomeblackahighervaluethanblack. Whileyoucangetvaluesdowntoblackbyeitherreducingbrightnessorincreasingcontrastalone, generallyusingbothtechniquesmoderatelyprovidesasubtlerexperiencethandoingonlyoneor theother.Applyingnoisereductionbeforeadjustinglumarangecanhelpyoureturnsomeofthe brighterblackpixelsclosertoblack,soyoucanusealessaggressivelumaexpansion. TheclassicAdobeLevelsfilterwithhistogramisinvaluableforthistypeofprocessing.Thekeyis tomakesurethattheregion,whichshouldbeblack,isbeingprocessedasblack.Ifbrightnessand
CompressionPrimer
21
contrastaren’tenough,youcanalsouseablackorwhiterestorefilter.Thesefilterssetathresholdbelowwhichallpixelsbecomeblack,andthosepixelsequaltooraboveitbecomewhite. Levelshistogram TheLevelsfilterinAfterEffects6 withtypicalsettingstosettheluma blackandwhitelevelsbeyondthat ofthenoisefloorandceiling.
Gammacorrection Gammaisameasurementofhowthe0-255lumarangeturnsintobrightnesswhenitisdisplayed.Withdifferentgammavalues,0and255appearthesameway,butvaluesinthemiddle oftherangeappeardifferently.Differentplatforms(Mac,SGI,andWindows)havedifferent defaultgammas.TheneteffectisthatsomefilesappeartohavebrightermidtonesonaMac thanonWindows.Thegoodnewsisthatmostmodernvideocodecsareabletoautomatically converttothepropergammasuponplayback. Unfortunately,thisisatransitionalperiodintheindustrywithalotofoldercodecsthatdon’t performgammacorrectionstillinuse.Forcontentthatyouneedtoplaybackcorrectlyona platformotherthantheoneitisauthoredfor,it’simportanttospotchecksamplesbyusingthat combinationtomakesuretheyappearcorrectly.
Audioprocessing Audiomayonlygetafractionofthebitsofvideo,butitmakesuphalftheexperience.While audioprocessingisgenerallyeasierthanvideoprocessing,itisimportanttocorrectlyprocess bothaudioandvideo. Resamplingaudio Forlowdatarates,especiallythosetargetingmodems,generallyyouneedtoreducetheaudioto alowersamplerate,typicallyto22.050KHzorlower.Moderntoolsautomaticallyusehighqualityalgorithmsforrateresampling,whichprovidemuchbetterqualitythanthedefaultsofa fewyearsago. Settingvolume Likedigitalaudioforvideoingeneral,thepeakvolumeshouldbeslightlybelowthemaximum volumeallowed.Byusingacompressor/limitertoreducedynamicrange,youcansometimes improveaudioqualityatverylowdatarates.Ingeneral,audiomixedfortelevisionbroadcast shouldencodejustfine. Adjustingchannelsandbitrates Monocontentencodesbetterthanstereoatlowerdatarates.Consequently,it’spreferableto converttheaudiofromstereotomonowhentargetinglowerbitrates(typicallyanythingbelow 32Kbps).
CompressionPrimer
22
Giventhechoiceofsettingaudiotostereoatalowersamplerateorsettingittomonoatahigher rate,youshouldchoosemonobecausesampleratemattersmorethanstereoforthecontent sounds. Afewhigh-endsystemsalsosupport5.1and7.1discreetsurround-soundaudio.Thedatarates requiredforthissurroundsound(128Kbpsandabovejustforaudio)generallyprecludetheir useinreal-timestreaming,buttheycanbequiteusablefordisc-basedplayback. DolbyProLogicencoded-surroundsound(whichstoressurroundsoundinastereopair) doesn’tsurvivetheencodingprocessintomanyaudiocodecs.IfProLogicencodingisrequired foragivenproject,testcarefullytomakesurethattheinformationissurvivingtheencoding process.Withsomecodecs,raisingthedatarateorturningoffoptionslikeJointStereomight help.Somecodecscan’tencodeProLogic. Reducingnoise Therearealsonoisereductionfiltersforaudio,althoughthesefiltersarenormallypartof professionalaudiotoolslikeAdobeAuditionTM,notapartofthecompressiontools.Providing clean,undistorted,hiss-andpop-freeaudiosourceresultsinbettercompression.
Encoding Ifpreprocessingistheartofcompression,encodingisitsscience.Encodingmeansdefiningthe correctparameters,likedatarate,framesize,andframerate,togetoptimumresultsforthe projectinquestion.Balancingtheseparameterscanbedifficultbecausetherearemanytradeoffs.Asalways,it’smostimportanttounderstandthegoalsthatthecompressedvideoismeant toachieve.Thissectionstartswithparametersthatapplytoallcodecsandcontinueswith parametersthatarespecifictovideoandaudio. Choosingadataratemode Differentcodecsandformatscanprovidedifferentdataratemodes.Someonlysupportone dataratemode,othercodecsprovideahalf-dozendifferentoptions.What’smostimportantis tounderstandhowthecompressedmediaisgoingtobeused—inmostcases,thereisasingle optimalmodeforaparticularuse. Youcanuseanyofthethesedataratemodes: •AveragelimitedThetraditionalandstillthemostcommonkindofdataratelimitationis averagelimited.Inthismode,youspecifytheaveragedatarate,andthecodectriestomake surethatthefileendsupattherequestedaverage.Thecodecvariestherateupordownto matchthechangingdifficultyofthevideo. MostCD-ROMandQuickTimecodecsstillworkthisway.Averagelimitedisusedformost progressivedownloadfileswherefilesizeanddataratearethelimitingfactors. •PeaklimitedApeaklimitedencodeisgenerallymeantforhardwaredevicesorhigh-data-rate contentwherethespeedofthedecoder(CPU,memory,ordisc)isthelimitingfactor.Specifyingaparticularpeaklimiteddataratedoesn’tmeanthepeakofthefilewillactuallybeatthe requestedbitrate.Thepeaklimiteddatarateisthemaximumratesupported,buttheencoder isfreetousealowerrateifappropriateforthecontent. Peaklimitedalsoworkswellforhigh-resolutionandhigh-data-ratewebandCD-ROMfiles thatneedtoplaybackonlower-endcomputers.Somecodecssupportencodingwithboth averageandpeaklimiting. CompressionPrimer
23
•BufferlimitedForreal-timestreaming,bufferlimitedencodingisthemethodofchoice.In bufferlimited,theaveragedatarateisn’tappliedtotheoverallfile,butitisappliedtoany givensectionofvideo.So,whenvideoisencodedwithathree-secondbuffer,anyarbitrary three-secondchunkofthefilehasadatarateatorbelowthetargetdatarate.Moststreaming encodedfilesuseaveragelimitedandbufferlimitedincombination.Bufferlimitedisoften calledconstantbitrateorCBR. •QualitylimitedQualitylimitedisdifferentfromtheothermethodsbecauseitdoesn’tspecify adatarate.Instead,itspecifiesaqualitytarget,andeachframeusesasmanyorasfewbits asneededtoreachthatqualitytarget.Thismodeisn’tcompatiblewithreal-timestreaming. However,itcanworkverywellforarchivingcontentorfordownloadingmissingcriticalvideo whereassuringqualityismoreimportantthanthefilesizeordownloadtime.Forexample, astockvideocompanymayusequalitylimitedencodedfilesforshortwebsamplestomake surethatthecontentlooksasgoodaspossibleanddoesnotwasteanybitsonunnecessarily highdataratesthatwouldmakethecontenteasytoencode. Mostquality-limitedcodecsspecifythequalityona0-100range.However,actualvisual qualityproducedbythesamevaluecanwidelyvaryamongcodecs.Somecodecssupport averageandqualitylimitedtogether;thequalitylimitsetsaminimumqualityforeachframe. Ifaframefallsbelowthequalitylimitbasedonavailablebitrate,thebitrateforthatframe israisedsoitwouldmeettheminimum.Typically,oneormoreframesafterthelow-quality framearedroppedtopreservetheaveragebitrate.Thismodesacrificessmoothmotionin favorofimagequality. Choosingbetweenencodingspeedandquality Manycodecsofferacontrolthatspecifiesatrade-offbetweenencodingtimeandquality.The fastermodestypicallyperformmuchlessexhaustivemotionestimation.Forthemostpart, bigspeedchangescausemuchsmallerqualitygains—aneighttimesslowerencodemightonly have20%bettercompressionefficiency.Thecorrecttrade-offbetweenspeedandqualityvaries dependingontheproject.ForDVDprojects,titlesunderanhourwon’tgainmuchbyslower, higher-qualityencodingbecausethedatarateissohigh.Web-distributedcontentalmostalways benefitsfromtheslower,higher-qualityencodedfilesbecausetherearealmostneverenough bitsforwebvideo. Settingframesize Framesizeisthenumberofpixelshighandwidethatformtheframeofthefinalvideo.It’salso sometimescalledresolution.Roughlyspeaking,thedatarateshouldchangeinproportionto theareaoftheframe(heightpluswidth).Thus,convertingfrom320x240to640x480would requireaboutfourtimesthedatarate,butconvertingto192x144,youcouldreducethedata ratedowntoone-thirdoftheamountitwasbefore.Theeffectisn’tquiteasstrongasthemath wouldsuggest;however,becausetherearefewerpixels,pixelqualitybecomesmoreimportant. Mostcodecsandformatsrequiretheheightandwidthofavideotobedivisiblebytwo.Most codecsgivebestcompressionefficiencywhenheightandwidtharedivisibleby16. Specifyingaspectratio Animportantfacetofframesizeisaspectratio.MostwebandCD-ROMformatsaresquare pixelbydefault,andmanyformatsonlysupportsquarepixel.Conversely,thedisc-basedVCD, SVCD,andDVDformatsarealwaysnonsquarepixel.It’simportanttofigureoutthetarget
CompressionPrimer
24
aspectratiofirst,andthenmakesurethattheframesizeyouchoosegivesthecorrectaspect ratiogiventhepictureshapeinwhichthecontentisdelivered. 4:3
16:9
160x112
208x120
192x144
256x144
256x192
336x192
320x240
432x240
384x288
512x288
512x384
688x384
640x480
848x480
Specifiyingthecorrectaspect ratio Suggestedframesizesfor4:3and 16:9aspectratioswhenworking withsquarepixels.
Adjustingtheframerate Framerateisthenumberofframespersecondatwhichthevideoruns.Higherframerates appearsmoother,andlowerframeratesappearchoppier.Anythingbelow20fpsdoesn’tappear smooth,andbelow10fps,thevideostartsappearingmorelikeafilmstripthanmovingvideo. Reducingorincreasingtheframeratehasmuchlesseffectthanframesizedoesonthedatarate becausereducingtheframeraterequiresencodingtwiceasmuchmotionforeachframe,which requiresmorebitsforeachframe.Also,eachframeappearsfortwiceaslong,sothere’smore timetonoticeeachartifact;thus,theimagequalityperframemustbehighertoprovidethe sameperceivedquality. Consequently,youshouldtrytousethesourceframerateifpossible,andnolessthanhalfthe sourceframerate,unlessyoutargetreal-timestreamingtomodemusers.Raisingframerates generallypaysoffmorethanraisingframesizesinimprovinguserexperience. NotethatNTSCframeratesare0.1%lowerthananintegernumber.So,“30fps”isreally 30/1.001,whichisconventionallyroundedto29.97.A29.97fpsoutputismoreaccuratethan30 fpswhendealingwithNTSCsource.Alsonotethatinterlacedvideohastwofieldsperframe, andyoucanturnthesefieldsintotwoframesonoutput.Soyoucanturn29.97fpsinterlaced sourceinto59.94fpsprogressive. Thereisanotherveryimportantrulewhenchangingframerates—theoutputframeratemust beanintegerdivisionofthesourceframerate.Therefore,theoutput,canbeone-halforonethirdthesourcebutnotthree-fifths.Goodframeratesforeachtypeofsourceappearinthe tablebelow. NTSC
24/23.976p
PAL
59.94
23.976/24
50
29.97
12
25
15
8
12.5
10
6
8.67
7.5
N/A
6.25
6
N/A
5
5
N/A
N/A
Suggestedframerates It’simportanttouseframerates thatareevenlydivisiblebythe sourceframerate.
CompressionPrimer
25
Negotiatingframedropping Somecodecs,optionallyorautomatically,canincreasethenumberofbitsspentondifficult framestomaintainimagequalitybydroppingtheframeratetokeepthetargetaveragedata rate.Thisprocessgenerallytakestheformofacontrolthatsetstheminimumimagequalityper frame.Ifthebitsthatthecodecwouldnormallyallocatetoagivenframearen’tsufficienttohit thetargetquality,itraisesthedataratefortheframetotheminimumrequiredforquality;then dropsoneormoreframesthatfollowtokeeptheaveragedatarateontarget. Whetherthisprocessisappropriatedependsonthecontent.Forentertainmentcontent,like moviesandespeciallymusicvideos,havingthevideosmoothlyinsyncwiththeaudioisimportant,sochoosingnottouseframedroppingisappropriate.Conversely,presentationvideo, especiallywithawhiteboardinthebackground,mightbebetterwithmanyframesdroppedand on-screentextremaininglegible. Howkeyframeratecomesintoplay Keyframeratecontrolsthenumberofkeyframes(I-frames)thatareinsertedinthevideo. Dependingonthetoolortheformat,keyframerateismeasuredinakeyframeeveryxframes orakeyframeeveryxseconds.MPEG-1andMPEG-2needalotofkeyframes;typicallytwoa second.Webformatsmighthaveonlyonekeyframeevery10seconds. Mostformatsalsoinsertadditionalkeyframes,callednaturalkeyframes,whenthevideo changesdramatically,likeatscenecuts,orwhenthereisextremelyfastmotion,likeinexplosions.Thesenaturalkeyframesresetthe“keyframeevery”value,soifavideohasalotofrapid cuts,itdoesn’tmatteriftheautomatickeyframesaresettoevery100or1000frames—allofthe keyframesarenatural.Forcodecsthatalsodonaturalkeyframes,the“keyframeevery”value reallyjustsetsamaximumdistanceamongkeyframes. Howkeyframesuse1-passand2-passalgorithms Historically,mostcodecsworkedinasinglepass—theyreadinthesourcefileandwroteoutthe compresseddataframe-by-frame.Thisprocesscertainlyworked,butitrequiredthedatarate mechanismtoguessthemakeupofthefuturecontent.Manygoodheuristicalgorithmshave beendevelopedforthisprocess,buteveryalgorithmguesseswronginsomecases.Theworst situationsarewhena1-passalgorithminterpretsthevideogettingmoredifficultandraises thedataratetokeepqualityconstant,orwhenanother,moredifficultsequenceisfollowinga fewsecondsbehindthecurrentframe;thenjustwhenthevideogetsthemostcomplicated,the codechastoreducethedataratebelowtheaveragetocompensateforthepreviouslyraisedrate. Ina2-passalgorithm,thecodecfirstanalyzesthevideoandbuildsatableoftherelativeencodingdifficultyineachframe.Thenitcalculatestheactualbitsperframeneededtoachievethe highestpossibleaveragequalityandappliesthesebitsinthesecondpass.Theneteffectisthe sameasaquality-limitedencodewherethecorrectqualityvaluereachesthetargetdatarate. Onebenefitabout2-passencodedfilesisthatthequalityisveryconsistent,sothattheeasier andtheharderpartsmorecloselymatch.Thisconsistencyislessjarringfortheuserthana videowheresomesceneslookgreatandotherslookterrible. Youcanuse2-passencodingwithbit-rate-,peak-,andbuffer-constrainedfilesiftheyaresupportedbytheformatandcodec.Withbufferlimited,largerbuffersgivethealgorithmmore flexibilitytodistributebits. Afewcodecshave3-passorN-passsystems.Withthesesystems,thecodecanalyzestheresults ofthesecondpass,buildsanewdatarateallocationtable,andencodesthefilewithhopefully
CompressionPrimer
26
betterresults.InN-passsystems,thecodeccanrepeatthisprocessmultipletimes,althoughobviouslydiminishingreturnssetinquickly(generally,agood2-passimplementationisalreadyvery closetotheoptimalresults). ModernformatslikeWindowsMediaandRealMediahave2-passintegratedintotheuserinterface. AVIandQuickTimecodecsthatsupport2-passhavemoredifficultymakingthiswork.WithAVI, thecodectypicallyneedstocreatetwodifferentencodedfiles—onedummyfileandonefullfile. Howsamplerateaffectsthequalityofaudio Samplerateisthenumberofaudiomeasurementsmadepersecond:44.1KHzforCD,48KHzfor DV,and8KHzforanalogtelephone. Anythinglessthan32KHzsoundsnoticeablydegradedcomparedtothesource.FormostbroadbandandCD-ROMuse,youshoulduseatleast32KHz. Unlessthespecsofthetargetcomputersareavailable,use44.1KHzforcomputerplayback.Itisa saferchoicethan48KHz.Manysoundcards,especiallyolderandcheapermodels,onlyplay44.1 KHzinternally,sobyusing48KHz,youforceasoftwaresample-rateconversion.Thisconversion isn’tasgoodasahigh-qualityfilterthatyoucanapplyatcompression,andsofinaloutputquality isworse.48KHzisafinechoicewithaudiosourceat48KHzorhigherandanoutputcomputer ordevicewithnativesupport.Afewcodecs,mostnotablyWMA9Professional,canalsoencodeat highersamplingrates,like96KHz. Note:Asmentionedpreviously,almostallaudiocodecsare16bit.WMAProfessionalisarecent exceptionthatcanusefullytakeadvantageofsourcesthatare20or24bit.Therearenoproblems inencodingfrom16-bitsourceto24-bitsource(noristheremuchadvantage). Channels Formostcodecs,channelsareachoicebetweenmonoandstereo.Somecodecsaremonoonly, stereoonly,oroptionallyoffermultichannelmodeslike5.1or7.1. Oldercodecs,likeIMA,requirethedataratetodoublewhengoingfrommonotostereo.Modern codecsareabletoencodethecontentthesameamongchannelsonlyonce,sotheadditionalbit raterequiredtoprovidestereoatthesameperceivedqualityismorelike20-50%ofthemonobit rate,dependingonthecodecandhowdifferentthechannelsare. Asdiscussedpreviously,channelsarelessimportanttoperceivedqualitythansamplerateorthe presenceofaudibleartifacts.A32-KHzmonosoundsbettertomostusersthan22.050-KHzstereo. Generally,youshouldusestereoonlyifyoucanuseatleastat32KHzandideally44.1KHz. Multichannel(5.1and7.1)audiocodecsalsoexist.ThemostcommonofthesecodecsareDolby Digital(AC-3)forDVDandWMA9Professional.MultichannelissupportedinRealAudio10.
Deliverymethodsforvideo Theonlyreasontocompresscontentistodeliverit;thewayyoucompresscontentdependsenormouslyonhowyouwilldeliverit.It’susefultounderstandthedifferentenvironmentsinwhich peopleusevideoandthetrade-offseachenvironmententails. Disc-baseddelivery ThefirsthalfofcompressedvideohistorywasintheCD-ROMera,whichwentfromtinyslide showstofull-screenandfull-motionwebvideo.Today,videoonmobiledevicesisbecomingavailable.Thegoodnewsisthatdiscplaybackkeepsgettingbetterevenasthefocusontheindustry progresses.
CompressionPrimer
27
Disc-baseddeliveryworkswell,andthedataratesavailableareradicallyhigherthanthosefor webvideo.Evenanancient8xIDECD-ROMcanprovideasustaineddatarateof8000Kbps!The limitonCD-ROMandDVD-ROMisn’taquestionofdataratebutofdiscspaceavailableand processorspeedtodecodeit.ThelargestCD-ROMdiscstodayare800MB.WithDVD-5giving 4.7GBandDVD-9upto8.4GB,DVDgivesvastlymoreroom. Whentargetingfasterpersonalcomputers,disc-basedplaybackcandoincrediblethings.Youcan playvideoat1280x720onmostcomputersshippedin2002,andyoucanplay1920x1080onthe high-endcomputersof2003.Youcaneasilyplayvideoat640x480oncomputersseveralyears old,especiallyifyouuseolder,performance-tunedcodecs(withacorrespondingreductionin compressionefficiency). Downloadablefiles Themostbasictypeofvideoonthewebisasimple,downloadablefile.Thefileisdownloadedto thelocalharddrivelikeanyotherfile. Theadvantageofdownloadablefilesisthatusersdon’thaveanyexpectationthatthey’llgetrealtimeplaybackwhilestreaming.Instead,theirbrowsertellsthemhowlargethedownloadablefile is.Thus,youcanuseveryhighdatarates.Also,becausethefileislocal,usersmightpassthefile amongthemselvesinsteadofeverypersondownloadingthefile,reducingthecostofbandwidth perviewer.Thedrawbackisthatuserscan’tviewanyofthefileuntilthedownloadiscomplete, whichcreatestheriskforuserstospendalotoftimedownloadingafiletheywouldhaverealized inthefirst10secondsthattheydon’twant. Downloadablefilesareoftenusedformarketingornoncommercialuse.Theyareverycommon invideogamesampleswhereveryhighdataratesarerequiredtoencodegameplayinsufficient quality. Progressivedownloadfiles Duringprogressivedownload,afileistransmittedthroughstandardwebprotocolslikeFTPor HTTP,butuserscanviewthepartthathasalreadybeentransmittedwhiletheremainderisstill transmitting. Withmostformats,thevideostartsplayingautomaticallywhentheamountoftimeremainingin thedownloadislessthanthedurationoftheclip.Thisformatallowsthecliptofinishdownloadingwhileitisplaying.However,insomecases,thevideoplaybackcatchesupwiththedownloadeddata,causingtheplaybacktopauseforamomentorlonger. BecauseprogressivedownloadusesprotocolslikeHTTPandFTPtoensurethatallpackets arrive,itisn’taffectedbythevideoandaudioglitchesassociatedwithreal-timestreaming.However,progressivedownloadcan’tprovidereliablereal-timeperformance.A400-Kbpsfileplaying overa200-Kbpsconnectiontakesnearlyaminuteofbufferingperminuteofvideo.Ofcourse, thatsame400-Kbpsfilecouldn’tstreamovera200-Kbpsconnection. Progressivedownloadistheeasiest,cheapest,andmostforgivingtypeofwebvideotoauthorand deploy.It’sagreatwayforusersnewtowebvideotostart. Real-timestreaming Thenextlevelofwebvideoisreal-timestreaming.Thisformatoffersthetraditionalexperience ofseeingthevideoafteronlyafewsecondsofbuffering,butitrisksimageglitches,poorquality, andlimitingthedataratetowhat’savailable. CompressionPrimer
28
So,whyputupwiththat?Becausereal-timestreamingprovidesreal-timeperformanceand randomaccess.Progressivedownloadworkswellwithamovietrailer,butnotformovies, especiallyiftheuserwantstoskiptothelast20minutes.Withrealtimestreamingthefilestarts playinginunderaminute,nomatterthelength,anduserscanskiptoexactlywheretheywant to.Also,mostreal-timestreamingformatsprovidescalability,whichallowsstreamstodynamicallyadapttotheuser’sconnectionspeed. Theuserexperienceofreal-timestreaminghasimprovedcomparedtoonlyafewyearsago. Codecsaremuchbetterandsoareservers.Althoughserverqualityisn’toftenadirectfocus,it hashugepayoffsfortheuser.Modernserversareabletoaggressivelymanagethebuffer,sending framesminutesbeforethey’reneeded,whichprovidesplentyoftimetoretransmitdropped packetsandadjustbandwidthbasedonchangingnetworkconditions. Peopleinthecompressioncommunityoftendebatewhentousereal-timestreamingandwhen touseprogressivedownload.Therearecaseswherethechoiceisobvious,andothercaseswhere thechoiceisnotsoobvious.Agoodruletoconsiderisduration—clipsunderthreeminutesare oftenbetterasprogressive,andclipsoverthreeminutesareoftenbetterasstreaming. Oneimportantfeatureofmodernreal-timestreamingisscalability.DataratesontheInternet aren’treliable.Connectivitythroughacablemodemcansubstantiallyvarythroughouttheday. ManyuserssharetheT1connectionandfasterpipestotheworkplace,leadingtorapidchanges inavailablebandwidthperuser. It’snotenoughtomeasurethedatarateatthestartofastream.Instead,theplayerandserver needtobeabletocommunicateinrealtimetotakeadvantageofalltheavailablebandwidth withoutsendingmoredatathancanbereceivedatanygiventime. Alloftoday’sscalableformatsworkbyputtingmultipleversionsofthevideoandaudiodata asdifferentstreamsinsidethesamefile.Thesescalablesolutionsareoftengenericallycalled multiplebitrate,orMBR.Thedetailsvaryandcanmatterasmuchasthecodecsthemselvesin providingagoodstreamingexperience.
Choosingacompressionformat Dependingontheproject,pickingthecorrectformatcantaketwosecondsortwoweeks. Sometimesthecustomermandatestheformat;othertimesacompressionisthastomakea recommendation.Sometimestheprojectrequiresfeaturesthatareonlyavailableinaparticular format.Perhapstherequirementshaven’tbeendetermined.Afteryouchooseaformat,youneed todeterminetheversionsofplayersthatsupporttheformat.Thissectionguidesyouthrough somequestionstoaskwhentryingtodecideonaformat. •FeaturesOftenthebiggestdeterminingfactorofaplatformisthefeaturesthatusersneed.If aformatcan’tmeettheprojectrequirements,it’sobviouslynotanoption.Ineveryproject, differentfeaturesvaryinthedegreeofimportance.Compressionefficiencyisalmostalways critical.Real-timestreamingscalabilityisanothermajorfeature. •UserbaseDependingontheprojectandaudience,userbasemaybeveryimportantornota concern.Withmostadvertisingcontent,usersareunlikelytodownloadawholenewplayeror codecjusttowatchsomeone’smarketingclip.Butforreallycompellingcontent,usersjump throughenormoushoops.Forexample,Apple®loggedseveralmilliondownloadsofQuickTimeinthe72hoursafterthePhantomMenacetrailerwasreleased. CompressionPrimer
29
•PlatformsSomeformatsareonlyavailableonasingleplatformorhavedifferentfeatures dependingonthetype,ortheversion,oftheoperatingsystem.Mostofthemodernmedia playersareavailableforatleastMacOS®andWindows;someareavailableonLinux®and otheroperatingsystems.Ifverybroadcompatibilityisrequired,anolderstandards-based format,likeMPEG-1,mightbeappropriate. Inmanycases,especiallywhenyoucreatecontentfortheInternet,itmaymakethemostsense todeploycontentinmultipleformatssothattheuserhasthechoice. Still,mostconsumersofdigitalmediahavealreadyinstalledtheplayersforthemajorformats. Whileitcanbetemptingtooffervariantsinfiveformatsatfourdatarateseach,itisgenerally bettertofocusonasfewformatsaspossibleandmakethreegreatfilesinsteadoftwentylowqualityfiles.
ExportingtoWindowsMediaformat WindowsMediaistheMicrosoftdigitalmediatechnology.OriginallyintroducedasNetShow, ithasmaturedverynicely,andtheWindowsMedia9platform,releasedearly2003,isavery strongproprietarydigitalmediaplatform. UsingWindowsMediaforstreamingdelivery WindowsMediaoriginallyfocusedonreal-timestreaming,andeventhoughithasbecomea morediversetechnologyovertime,real-timestreamingisstillacorefocus.WindowsMedia9 hasanexcellentstreamingarchitecture,excellingwithMBRtechnology,servers,andcodecs. TheMBRsolutioninWindowsMediaiscalledIntelligentStreaming.PriortoWindowsMedia 9,itwasrelativelylimited,handlinguptofivevideodataratebandsperfile,butallofthesedata ratebandsneededtosharethesameresolutionandaudiotrack. IntelligentStreamingwasenormouslyimprovedwithWindowsMedia9.Now,itcanuseover adozendataratebandsforbothvideoandaudio.Thevideobandscanvaryresolutionaswell, makingitpossibletoprovideasinglelinkthatcanscalefromaudio-onlyformodemuptohigh definitionplaybackforalocalareanetwork(LAN).TheonlysignificantrestrictiontoIntelligent Streamingnowisthatallbandsmustsharethesamecodecandencodingmode(forexample, WindowsMedia9witha2-passCBR). TousethenewWindowsMedia9IntelligentStreamingoptions,youneedtorunMicrosoft WindowsServer™2003.IfyouaremakingafilethatneedstoworkontheolderWindows MediaServer4.1forMicrosoftWindowsNT®andWindows2000,usethesameresolutionfor allvideobandsandonlyuseasingleaudioband.Olderplayers(earlierthanWindowsMedia9) alsoneedtouseasubsetoftheavailablefeatures. UsingWindowsMediaforprogressivedownload EarlierversionsofWindowsMediaweren’tsuitableforprogressivedownload,butthischanged withWindowsMedia7.1andlater.Nowtheplayersreliablyplaypartiallydownloadedmaterial, andtheencoderssupportdownloadoptimizedmodes,like2-passbitratelimitedVBR. UsingWindowsMediafordisc-baseddelivery WindowsMediaworkswithCD-ROMandDVD-ROM,aslongasWindowsMediaPlayeror anotherMicrosoftDirectShow-basedplayerisused.However,becausedataratesaremuchless limitedondiscs,peakdataratesthatCPUscandecodemaylimitplaybackperformance.The peakconstrainedVBRmodecanbeusedinthosecasestoguaranteeperformanceontheminimumplaybackplatform.
Extensions Therearemanydifferentfiletypes andextensionsavailablefor WindowsMedia.Herearesomeof themostcommonextensionsand theirmeanings: .asf ThefileformatusedforWindows MediafilesiscalledtheAdvanced StreamingFormat,andtheoriginal extensionwas.asf.However,thisextensiondidn’tdiscriminatebetween audio-onlyandvideofiles,and sotheextensions.wmvand.wma wereaddedwithWindowsMedia7. Today,.asffilesaretypicallylegacy contentusingtheMicrosoftMPEG4v3videocodec.However,thefile formatitselfhasn’tchanged. .wmv AWindowsMediaVideofile(.wmv) isan.asffilethatcontainsvideo. .wma AWindowsMediaAudiofile(.wma) isthesameasan.asffile,butitonly containsaudio. .asx An.asxfileisametafileforWindows MediaStreaming.The.asxfile goesonthewebserverandpoints towardthemediaonthestreamingserver.The.asxfileformatitself hasn’tchanged,butwiththeadvent ofWM7,the.wvxand.waxfile extensionshavebeenusedmore commonly. .wvx A.wfxfileisametafilethatcontains videoand,optionally,audio. .wax A.waxfileisametafilethatcontains onlyaudio.
CompressionPrimer
30
TheMacromediaDirectorCD-ROMauthoringenvironmentcan’tuseDirectShowforvideo playbackoutofthebox.TouseWindowsMediafilesinDirector,youneedathird-partyplug-in. ThereisagrowingnumberoftitlesusinghighdefinitionWindowMedia9contenton DVD-ROMdiscs.Whilediscsrequireafastcomputerforplayback,WindowsMedia9isprovingtobethefirstviablehigh-definitiondiscformat.
WindowsMediaplayers ThereisawidevarietyofdifferentWindowsMediaplayersavailablefordifferentplatforms, makingcompatibilityamovingtarget.Recentplayersaren’tcurrentlyavailableforsomecommonoperatingsystems,whichforcesalowestcommondenominatorthatprovidesmultiple versionsofthecontentorexcludessomeplatforms.Thefollowinglistdescribesthemostcommonlydeployedplayers. WindowsMediaPlayer6.4forWindowsandWindowsNT WindowsMediaPlayer6.4shippedwithWindows98andWindows2000,anditisthemost recentversionavailableforWindows95andWindowsNT.Windows95doesn’thaveanappreciablemarketsharefordigitalvideoconsumers,butWindowsNTisstillcommononcorporate desktopsandmattersasadeliveryplatform.WindowsMediaPlayer6.4isverylimitedingeneral,bothinperformanceandfeatures.Connectingtothesamecontentoverthesameconnection,WindowsMediaPlayer6.4haslengthierbufferingtimesandlessreliableplaybackthanthe newerversions. WindowsMediaPlayer6.4isshippedwithMicrosoftMPEG-4version3asitsmostadvanced codec.However,theplayercanautomaticallyupdatethroughWindowsMedia9.Thisupdate requiresadministratorprivilegesonthecomputerandafirewallthatallowsthedownload. ThereisalsoanenterprisedeploymentpackthatInformationTechnologydepartmentscanuse toprovidetheupdatedcodecsinanetwork-widesystemimage.WindowsNTsystems typicallyrunonolderhardware,andsotheremaybeperformanceissuesplayingmodern codecsonthosesystems. WindowsMediaPlayer6.4can’tworkwithnonsquarepixelsorinterlacedvideolikeWindows MediaPlayer9,butthosefeaturestypicallyrequireafasterCPUthanWindowsNTcomputers arelikelytoberunningon. WindowsMediaPlayer7.1forWindows WindowsMediaPlayer7.1forWindowsisavailableforWindows98,MicrosoftWindowsME®, andWindows2000,andisshippedwithMicrosoftWindowsXP®.WindowsMediaPlayer7.1 forWindowscanbeautomaticallyormanuallyupdatedtothelatestcodecs,butitismissing afewfeaturesofthelatestWindowsMediaPlayer9.Specifically,itcan’tdomorethantwochanneloutput(5.1and7.1sourcesaremixeddowntostereoforplayback)orinterlacedand nonsquarepixelplayback.Still,forwebvideoapplications,WindowsMediaPlayer7.1isnearly asgoodasWindowsMediaPlayer9. WindowsMediaPlayer9forWindows WindowsMediaPlayer9forWindowsrunsonthesameplatformsasWindowsMediaPlayer7.1 andmaydisplaceitovertime.ItonlystartedshippingasastandardapplicationonWindowsXP inthesummerof2003. WindowsMediaPlayer9supportsthefullsuiteoffeaturesforWindowsMediaVideo9andis theonlyplayerwithsupportforthenewfeatureslikemultichannelaudio,interlacedvideo,and nonsquarepixels.
CompressionPrimer
31
WindowsMediaPlayer9forMacOSX(10.1andlater) Inlate2003,MicrosoftreleasedanupdatedMacOSplayerwithsupportfortheWMV9and WMA9codecs.Otherwise,theupdatewasquitesimilartotheolderMacOSplayers,which lackedsupportfornonsquarepixelsandinterlacedvideo.Performanceforlowerresolutioncontentisquitegood,buteventhefastestG5computerscan’tplayhighdefinitionWindowsMedia Player9contentyet.NotethatnoneoftheMacOSXplayershavesupportedtheolder,butstill common,ACELP.netspeechaudiocodec. WindowsMediaPlayer7.0forMacOS“classic”(MacOS8.1-9.x) TheearlyversionsofWindowsMediaPlayerforMacOSwereproblematic.Butwithversion7, theMacOSsolutionbecamequitegood,tothepointwhereWindowsMediabecameapopular alternativeplatformfordeliveringreal-timestreamingcontenttoMacs. ThecurrentMacOS9solutionissimilartotheWindowsMediaPlayer6.4playerbecauseituses theoldscriptingandDigitalRightsManagement(DRM)modelandsupportscodecsthrough WindowsMediaVideo8,WindowsMediaAudio,andACELP.net. WindowsMediaPlayerforPocketPC2003 CurrentMicrosoftWindowsMobilePocketPCscanalsoplayWindowsMediawithWMV7,8, or9,andWMA.NotethatmanyPocketPCshaveslowprocessorsandvideoperformance,so resolution,framerate,anddatarateneedtobemuchlowerthanforcomputerplaybackifyou targetawidevarietyofdevices.Ideally,youshouldtargetonlyaparticularmodelsouserscan tunesettingsforidealplayback. Forhigher-endPocketPCs,reasonablesettingsforWMV9wouldbe320x240atthenative framerateand300Kbpsdatarate.AnyWMA9audioisfine,upto48KHzstereo. PocketPCplaybackisnormallylocal,butthePocketPCplayeriscapableofreal-timestreaming ifithasawirelessInternetconnection. WindowsMediaPlayerforPocketPC2002 WMPforPocketPC2002isonlysupportedthroughWMV8.Italsoofferslowerperformance becauseitwasavailableonlower-performancehardware. WMPforPocketPC2000 WMPforPocketPC2000issimilartothatfor2002,butitonlysupportsWMV7,notWMV8. Also,PocketPC2000devicestendtobeslowerthan2002devices,whichrequireevenmore conservativecompressionsettings.
WindowsMediaencodingmodes WindowsMediahasavarietyofencodingmodes,eachofwhichisappropriatefordifferent typesofuses.Theterminologycanbeconfusing,soit’simportanttounderstandthemodesthat areoptimalforthegivenuses. Unlikeotherformats,thesedataratemodesapplytobothaudioandvideoformanycodecs. SomecodecsareCBRonly,however. CBR CBRisanabbreviationforconstantbitrate.CBRisthemodeoptimizedforreal-timestreamingbyuseofWindowsMediaServicesCBR.CBRalwaysneedstobeusedforstreaming.CBRis alsoneededforreliableplaybackonthelegacyWindowsMediaPlayer6.4forWindowsNTand Windows95. CompressionPrimer
32
WhenencodingCBR,theuserdefinesabuffersize(bydefaultthreeseconds).Largerbuffer sizesincreasecompressionefficiencybutalsoincreaselatency.Thelatencyincreaseisminimal withWindowsMediaPlayer7andlater,buttheminimumlatencywiththeWindowsMedia Player6.4isalwaysatleastashighasthebuffersize,evenforlocalplayback. CBRencodedfilesalsouseavalueof0-100thatisoftenlabeledasaqualitymeasurement,but isbetterunderstoodasspecifyingatrade-offbetweenimagequalityandprovidinganaccurate framerate.Withavalueof0,noframesaredropped,andtheimagequalityisasgoodorpooras ispossiblegiventhecontentanddatarate.Valuesgreaterthan0setaminimumqualitythresholdforeachframe.Ifthequalityforagivenframedropsbelowthatvalue,itsdatarateisraised untilitmeetsthequalitytarget.Ifthedatarateoftheclipisexceeded,oneormoreframesare droppedtomaintainthedatarate.Droppingframesthiswaycanresultinavideowithajerky appearance. 1-pass ThedefaultmodeforWindowsMediaencodingis1-passCBR.Theadvantageof1-passencodingisthatitistwiceasfastas2-passCBR.However,itdoesn’tofferthecompressionefficiency of2-passCBR. 2-pass 2-passCBRmodeoffersbettercompressionefficiencythan1-passCBR,especiallywithhighly variablecontentandlargerbuffersizes.WheneveryoucreateCBRfiles,use2-passCBR,iftime allows. Quality-limitedVBR Quality-limitedVBRisa1-passVBRmodeforwhichimagequalityisspecifiedinsteadofthe datarate.Insteadofrequestingadatarate,aqualityvaluefrom0-100isassigned.Thesevalues arethesameasfromthecontrolinCBRforcontrollingimagequalityandframerate.Thefinal datarateofthefiledependsonthecomplexityofthecontent. Quality-limitedVBRistheonly1-passVBRmode,anditisbestusedwheredatarateisn’tan importantconstraint,likemakinganarchiveforlateruse.AsaVBRmode,itisn’tcompatible withstreamingorplaybackinWindowsMediaPlayer6.4.NowthatproductslikeAfterEffects andAdobePremiereProcanuseWMVfilesassourcefiles,archivingtoWMVwithahighfile ratecanbeagoodwaytocompactlystorebroadcastqualityvideo. Bit-rate-limitedVBR Bit-rate-limitedVBRisa2-passencodingmodeforfile-baseduse.UnlikeCBR,itdoesn’thavea buffersizeorqualitylimit. Theeffectofabit-rate-limitedVBRisessentiallythesameasaquality-limitedVBR.Thequality valuethatprovidesthetargetdatarateisused.Ineffect,thefirstpasssimplydeterminesthe qualityvaluethatwouldproducetherequestedfilesize. Bit-rate-limitedVBRistheoptimummodeforfile-basedprojectsforwhichtotalfilesizeisthe limitingfactor,mainlyaffectingprogressivedownload. NotethatVBR-encodedfilescanhaveplaybackissuesonWindowsMediaPlayer6.4.Theywon’t crashtheplayergenerally,butplaybackperformancecanbepoor.Use2-passCBRinsteadwhen targetingthisplayer.Theothermajordrawbackofbit-rate-limitedVBRisthatitcanhavehighdata-ratepeaks,whichcancauseplaybackissues.Peak-limitedVBRaddressesthatissue. CompressionPrimer
33
Peak-limitedVBR Peak-limitedVBRisaspecialtypeofbit-rate-limitedVBR.Itworksthesameasbit-rate-limited VBR,butithastheadditionsofpeakdatarateandbuffersizeparameters.Theseadditionsare usedtospecifyamaximumdataratethatwon’tbeexceededwithinanysectionofthefileupto thebuffersize. Considerpeak-limitedVBRwhenplaybackperformanceorpeakdatarateisaconcern,likewith veryhigh-data-ratefiles,orplaybackonslowercomputersorsloweropticaldrives.Thereisno drawbacktopeak-limitedVBRversusbit-rate-limitedVBRifthepeakbitrateishighenough. AsconsumerelectronicdevicesadoptWindowsMedia,documentationshouldbeavailable definingappropriatepeakvaluesfordifferentuses.
WindowsMediavideocodecs WindowsMediahasabroadsetofcodecsavailable,butthereisgenerallyonlyonecodecthatis theobviouschoiceforaparticularproject. WindowsMediaVideo9codec WMV9isaleadingvideocodecwithexcellentresultsinavarietyofusesthatscalefrommodem tohighdefinition.Itprovidesgreatcompressionefficiencyandgoodspeedforbothencodeand decodeprocesses. Sofar,thebiggestdrawbackforWMV9isthatitisonlypreinstalledwithrecentversionsof WindowsMediaPlayeronWindowsandMac. WMV9isthefirstvideocodecinWindowsMediathatsupportsinterlacedandnonsquarepixel video.Whilenotusefulforwebapplications,thiscodecmakesWindowsMediamuchbetterfor consumerelectronicsandvideoauthoringworkflows. WindowsMediaVideo8codec WMV8doesn’tofferthecompressionefficiencyofWMV9(maybe20%lower),nordoesithave thenonsquarepixelorinterlacedmodes.However,itdoeshavethevarious2-passandVBR modesofWMV9.WMV8isprobablythebestchoiceformostmainstreamWindowsMedia projectsiftheplayerversionisn’tknowninadvance. TheadvantageofWMV8isthatitissupportedonalmostallplatformsofinterest.TheseplatformsincludeWindows95andWindowsNT,MacOS9andX,andPocketPC2002.Thecodec ispreinstalledontheMacplayers,PocketPC2002andlater,andWindowsMediaPlayerfor Windows7.1andlater. WindowsMediaVideo7codec MostplayersthatcansupportWMV7alsosupportWMV8now.TheoneexceptionisPocketPC 2000,whichcan’tupgradetoWMV8. MicrosoftMPEG-4version3codec TheolderMicrosoftMPEG-4v3codecislessadvancedthanWMV8andWMV9incompression efficiency.However,itisthemostrecentcodecavailablebydefaultinthestockWindowsMedia Player6.4.Itisgenerallytheoldestcodecavailableinmodernencoders. ISOMPEG-4version1codec TheInternationalOrganizationforStandardization(ISO)MPEG-4codecisanimplementation ofthestandardsimplevisualprofileofMPEG-4.However,theWindowsMediaformatdoesn’t supporttheMPEG-4fileformat,streaming,oraudiocodecs.WMV7includestheMPEG-4 codectoprovideuserswithaccesstoMPEG-4.
CompressionPrimer
34
WindowsMediaVideo9screencodec WMV9screencodecisoptimizedforscreenrecordings,likethoseusedinsoftwaretutorials. Unlikescreencodecsfromothervendors,ithasanexplicitdataratecontrol,whichmakesit workwellforstreaming. Screencodecsworkbestforsourcethatislikescreenanimation,inotherwords,RGBsource wheremostofeachframeisidenticaltotheframebeforeit.Itcanalsoworkforsometypesof flatcolormotiongraphics. WindowsMediaScreenversion7codec WindowsMediaScreenversion7isanolderversionofWMV9Screen.Ithassomewhatlower compressionefficiency,butotherwiseitworkssimilarlytoWMV9Screen.
WindowsMediaaudiocodecs WindowsMediaalsohasavarietyofaudiocodecstunedfordifferentuses. WindowsMediaAudio9codec WindowsMediaAudio9codecisthelatestversionoftheWMAencoder,anditsoutputisbackward-compatiblewiththeearlierWMA2decoder.AnyversionofWindowsMediaPlayerstillin useshouldbecompatiblewithWMA9.NowthatthereareothercodecswiththeWMA9prefix, theoriginalWMAisnowgenerallycalledWMAStandard,althoughitdoesn’tappearthatway inencodingtools.InthisdocumentWMA9referstothestandardcodec. WMA9nowsupportsalloftheWMA9bitratemodes.However,youshoulduseCBRmodeif compatibilitywithWindowsMediaPlayer6.4isrequired.NotethatthebitrateVBRmodehas amorelimiteddataraterangeof48-192Kbps,butitoffersCBR,whichcanrangefrom5to320 Kbps.Also,thequality-limitedVBRmodedoesn’tprovideafull0-100range,butitoffersafew discreetoptionsinthecodecdataratepop-upmenu. Thereisa0KbpsoptionforWMA9CBRaswell.Thisoptionisformakingaudio-freestreamingfilescompatiblewiththelegacyWindowsMediaServices4.1usedpriortoWindowsServer 2003.IntelligentStreamingforthatserverrequireseachfiletohaveoneandonlyoneaudio track,sothe0Kbpsoptionprovidesawaytohaveanaudio-freefile. ACELP.netcodec ACELP.netisalow-bit-ratespeechcodec.ItsoundsbetterthanWMA9forspeechcontentbelow 24Kbps.However,thedecoderisn’tavailableonallplatforms—it’smissingfrombothMac OSXandPocketPC. WindowsMediaAudio9Voicecodec WMA9Voiceisalow-bit-ratespeechcodecandreplacesACELP.net. WMA9Voiceperformsdecentlywithmusiccontentatverylowbitrateswhenplayedinthe musicormixedmodes.WMA9VoiceisalsoknownasWMA9Narrowband.Itisgenerallya betterchoicethanWMA9formusicat20Kbpsandbelow. NotethatWMA9VoiceismonoandhasaCBRonlywithamaximumsamplerateof22KHz andamaximumdatarateof20Kbps.It’sonlyappropriateforlow-bit-rateapplications. WindowsMediaAudio9Professionalcodec WMA9Professionalisanewcodecformultichannelandhigh-resolutionaudio.Itrequiresdata ratesofatleast128Kbps,soitisn’tappropriateformostwebcontent.Itwasthefirstcodecin oneofthemajorarchitecturestosupportmorethantwoaudiochannels,samplerateshigher
CompressionPrimer
35
than48KHz,andbitdepthsgreaterthan16bits.Youshoulduseitonlywithsourcethatrequires oneofthosefeaturesgivenitshigh-data-raterequirements.High-bit-rateWMA9doesjustfine withstereo16-bitsourcesat48KHzorless. MultichannelWMA9Professionalplaysbackonsystemswithonlystereospeakers,combining channelsintelligently.Itcanalsofolddownwellinothercases,like7.1to5.1,ortoleft,right,and centergamingsystems.Still,multichannelisbesttousewhenyouanticipateasignificantnumber oflistenerswhohavemultichannelaudioplayback. WMA9ProfessionalsupportsallofthedataratemodesofWindowsMedia9,including2-pass CBRandallthreetypesofVBR.Asalways,youshoulduse2-passCBRforstreamingandVBRfor file-basedplayback. WindowsMediaAudio9Losslesscodec TheWMA9Losslesscodecisamathematicallylosslesscodecforarchivingaudio.Becausealosslesscompressioncan’tguaranteeanyparticulardatarate,itisonly1-passVBR.WMA9Lossless worksonthesameplayersasWMA9Professional.Losslessisoverkillfordeliveryandyoushould onlyuseitforarchivingandmastering.ItisalsopopularfordigitallyarchivingaudioCDcontent.
ExportingtoRealMediaformat RealMediaistheoldestreal-timestreamingwebformat;thepioneeringRealAudioshippedin 1995.RealNetworkshascontinuedtoenhanceit;theupdatedReal10platformwasannouncedin January2004. UnlikeWindowsMedia,mostRealMediatoolsspecifythetotaldataratefromwhichaudiodata rateissubtractedtoleavevideodatarate.However,sometoolsdon’tusethismethod—it’simportanttoknowthemodeaparticulartooluses. UsingRealMediaforstreamingdelivery RealMediawasthefirststreamingplatform.RealMediadoesgreatinastreamingenvironment. ItsMBRsolutioniscalledSureStream.UnlikeWindowsMedia,itcanmixandmatchcodecsin differentstreams.Allstreamsmustsharethesameframesize,whichcanlimitscalability. UsingRealMediaforprogressivedownload WhileRealMediaismainlyconsideredastreamingformat,ithassupportedtheexcellent.rmvb 2-passVBRprogressivemodeforseveralyears.Thesefilesactuallyuseadifferentextensionthan thestandard.rmfiles,indicatingthatthefileswon’tworkwhenplacedonastreamingserver. UsingRealMediafordisc-baseddelivery The.rmvbfilesalsoworkfinefromCD-ROMorDVD-ROM.Whilemostsoftwaretools,like MicrosoftPowerPoint,don’tallowRealMediafilestobedirectlyembeddedinthem,thefiles playwellfromthediscintheRealOneplayer.RealMediaisalsoagoodhigh-definitionplayback solution.ItscodechaslighterdecoderequirementsthanWMV9,whichallowshigh-resolution playbackonlower-endcomputers.ThenewReal10alsoincludesmultichannelaudiosupport.
RealMediavideocodecs RealMediasupportsasmallersetofvideocodecsthantheotherformats.Themostrecentcodecis alwaysthebestchoice. RealVideo10codec ThenewRealVideo10isabackward-compatibleenhancementtoRealVideo9.Comparedtothe oldercodec,itofferssignificantlyimprovedcompressionefficiencyandacontroltoadjustcompressionqualityandencodingtime.
CompressionPrimer
36
RealVideo9codec TheRealVideo9codecisanexcellentgeneral-purposevideocodec.Itscaleswellfrommodem datarateandmobiledeviceplaybackonthelowenduptohigh-definitionplaybackatthehigh end. RealVideo9comesstandardwithRealOnePlayer(Windows,andMacOSX)andisanautomaticcodecupgradeforRealPlayer8(thelastversiononMacOS9). RealVideo8codec RealVideo8wasthepreviousversionofRealVideo.RealVideo9isalmostascommonas RealVideo8andoffersbettercompressionefficiency,soitisgenerallybettertouseRealVideo9 instead. RealVideoG2codec RealVideoG2wasthefirstmodernRealVideocodec.ItisonlyrequiredbyoldRealPlayerinstallations.
RealMediaaudiocodecs Unlikeotherformats,aRealAudiocodecisdefinedbyacombinationofacodec,datarate, samplerate,andchannels.Insteadofpickingacodecandotherparameters,theuserpicksan inclusivecombination.AnothertwistwiththeRealMediaaudiosupportisthatmanytools requireaudiocodecstobespecifiedforvideoandmusiccontent,forbothvideoandaudiofiles andaudio-onlyfiles.Theuserpickstheonebasedonthemodethefilewasencodedwith.It’s importantfortheusertopickthecorrectsettingforthemodethatisactuallybeingused. RealAudio10codec RealAudio10usestheoldRealAudio8StereoMusiccodecforbitratesbelow128Kbpsand AAC-LCforhigherbitrates(Sony’sATRAC3wasusedforhigherbitratesinpreviousversions). Thecodecisbackward-compatibletoRealPlayer8atlowerbitratesbuttheplayerrequiresan updateforhigherbitrates. RealAudio10Losslesscodec ThiscodecrequiresRealPlayer10.Dataratesareestimatedto700Kbpsfor44.1stereo,sothis codecisn’taweborstreamingsolution. RealAudio10Multichannelcodec Thiscodecisa5.0or5.1channelcodecthatrequiresRealPlayer10.Itrequireshighdatarates, soitisnotastreamingsolution. RealAudio8StereoMusiccodec RealAudio8StereoMusicistheleadinggeneralpurposeaudiocodecintheRealMediaformat. ItscompressionefficiencyisbetterthanthemonoRealAudioMusiccodec,soitworkswelleven formonoaudioandatdataratesaslowas12Kbps. Atsomedatarates,a“high-frequency”variantofthecodecisavailable.Thishigh-frequency variantprovidesabroaderfrequencyrange.However,withcomplexaudio,itcanalsoresultin moreartifacts.Youneedtoexperimenttofindthesettingsthatworkwellfordifferenttypesof content. RealAudio8Surroundcodec TheRealAudio8SurroundcodecisavariantoftheRealAudio8StereoMusiccodec.Itisn’t actuallyatrue5.1or7.1system.Insteaditstoresastereopair,butitcanmaintainDolbyPro Logicsurroundsoundencoding,whichthebaseRealAudio8StereoMusiccodeccan’t.While
CompressionPrimer
37
thiscodecdoesn’tprovidethefullmultichannelexperience,itiscompatiblewithawiderange ofequipment. ThiscodecisappropriateifthesourceisaDolbyProLogicsurroundsoundmix.Fornormal stereomusic,theRealAudio8StereoMusiccodecprovidesbetterqualityandmoreflexibledata rateoptions. RealAudioSpeechcodec TheRealAudioSpeechcodecisarelativelystandardspeechcodec;itisintelligibleatthelowest dataratesandcansoundexcellentathigherdatarates.Unlikemostspeechcodecs,itprovides 32-and64-Kbpsoptionswithexcellentfidelityforcontentsuchasaudiobooks. RealAudioStereoMusiccodec TheRealAudioStereoMusiccodecistheoriginalRealAudiostereocodecfromtheG2release. ItofferslowercompressionefficiencythantheRealAudio8StereoMusiccodec.Thiscodec providesextensivebackward-compatibility. RealAudioMusiccodec TheRealAudioMusiccodecistheoriginalRealAudiomonocodecfromtheG2release.Even formonocontent,theRealAudio8StereoMusiccodecprovidesbetterquality.However,the RealAudioMusiccodecisavailableatlowerdataratesthantheRealAudio8StereoMusiccodec, soitcanbeusefulinsomecasesforlowbitrates.
ExportingtoQuickTimeformat QuickTimeistheoldestofthemainstreamdigitalmediaformats;itwasintroducedbackin 1991.ItpredatestheInternetandeventheCD-ROMdriveasstandardcomputerequipment, andithasmaturedtosupportawidevarietyofapplications(althoughitislessadvancedthan RealMediaandWindowsMediaforreal-timestreaming).ThegreateststrengthofQuickTimeis thatitsupportsrichinteractivityandrichmedia. Bydefault,QuickTimedatarateissetastotalkilobytespersecond,notthetotalkilobitsper secondofRealMediaorthekilobitsperstreampersecondofWindowsMedia.However,many toolsthatsupportmultipleformatsprovidetherateinKbits.Forconsistency,dataratesare listedinKbitsbelow. NotethissectionisabouttheQuickTimeformat(.mov),notabouttheQuickTimearchitecture, whichcanauthorandplaybackmanyotherformats,includingMPEG-4andAVI.
Moviealternates QuickTimetakesaverydifferent approachtoscalabilityfromWindowsMediaandRealMedia.Instead ofmakingasinglefilethatcontains multipleversionsofthedataat differentdatarates,QuickTimeuses multiplefilesatdifferentdatarates, whichareswitchedwhenthemovie beginsplayingback. Thereareseveraldrawbackstothis approach.First,theswitchingonly takesplacewhenthefilebegins playing,sothereisnoswitching supportedduringplayback.Second, authoringismorecomplex—only afewadvancedcompressionproducts,likeAdobeMediaExporter, supportauthoringthealternate movieswhileencoding.Third, QuickTimereliessolelyontheuser tocorrectlyconfigueQuickTime preferencestodeterminethedata rate.SoifausersetsupQuickTime onalaptopwithabroadbandconnectionatwork,andthenconnects bymeansofamodemfromahotel room,QuickTimetriestotransmit thebroadbandversionofthefile andeitherfailsdramaticallyifitis real-timestreamingorcausesavery lengthydownloadforprogressive files. Forthesereasons,itisbesttooffer usersdirectlinkstoeachmedia file,evenifyoualsoofferageneral moviealternateslink. Therearesomeuniquefeatures ofmoviealternates.Forone,they workwithprogressivefiles,not juststreamingfiles.Foranother, theycanfilterinmoreparameters thanjustdatarate.Youcanprovide differentversionsforMacOSand Windowsusers,forcomputersusing differentlanguages,andforcomputerswithdifferentCPUspeeds.
UsingQuickTimeforreal-timestreaming QuickTimedoesn’thaveareal-timescalabilitysolution,likeSureStreamorIntelligentStreaming.QuickTimecanbeapoorfitforreal-timestreamingontheInternetbecausedataratesare sovariable.However,QuickTimecanworkwellinanintranetenvironment.Oneadvantageis thatthestreamingserveristhefree,opensourceDarwinStreamingserver,availableforavast varietyofplatforms. QuickTimeaddedstreamingsupportrelativelylateinitsdevelopment.Unliketheotherformats wherefilesarealwaysstreamable,inQuickTime,youhavetoaddhinttrackstofilesyouwantto stream.Thisextradatagivesinstructionstotheserverabouthowtostreamthedata.Notethat thedataitselfisn’tsent,sothefilesizeofahintedmovieislargerthantheamountofdataactuallybeingsenttotheclient.
CompressionPrimer
38
UsingQuickTimeforprogressivedownload QuickTimepioneeredprogressivedownload,andthisformatremainsthemostpopularwayto distributewebvideowithQuickTime. OnecomplexitywithprogressiveQuickTimemoviesisthattheyneedtobefast-startingmovies. EveryQuickTimemoviehasamovieheader,whichcontainsinformationaboutthefile’sstructureandisrequiredforplayback.Wheneveryoumodifyafile,QuickTimemovesthemovie headertotheendofthefile,whichmeansthatitwon’tstartquicklyandonlytheQuickTime logowillplayuntiltheentiremovieisdownloaded.Eveneditingmetadata,likethemovietitle, canforcethischange.Thesimplestwaytomovetheheadertothebeginningofthefileisto performa“SaveAs”fromwithinQuickTimePlayerPro. Don’tusehinttrackswithprogressivefilesbecausetheyaren’tused,andtheyincreasethefile size.Instead,usetheCompressedMovieHeadermodewithprogressivefilesbecauseitmakes theheadersmaller. UsingQuickTimefordisc-baseddelivery QuickTimeisagreatsolutionforCD-ROMandotherdisc-basedarchitectures.TheQuickTime APImakesitveryeasytoaddQuickTimeplaybacktoapplications,andQuickTimeisthebest supportedformatinsideDirector.However,PowerPointonWindowsdoesn’tnativelysupport QuickTime.
QuickTimevideocodecs GiventhelongheritageofQuickTimeforflexibilityandsupportforthird-partycodecvendors, therangeofcodecssupportedinQuickTimeisbroaderthanintheotherformats.However,the bestcodecsareoftennotprovidedforfree. SorensonVideo3codec ThehighestqualitycodecavailableforQuickTimetodayisSorensonVideo3fromSorenson Media.Itisaveryflexiblecodecandcanworkinbothprogressivedownloadandstreaming environments.Thebasicversiondoesn’tincludeavarietyofadvancedfeaturesthatimprove compressionefficiencyandstreamingperformance. QuickTimecomeswiththefree,basicversionofSorensonVideo3.However,forprofessional use,theSorensonVideo3.1Professionalupgradeisavailable.SorensonVideo3.3Prooffers improvedcompressionspeeds,especiallyondual-processorcomputers,andimprovedquality, especiallywithreal-timestreamingprotocol(RTSP)streaming.TheProversionisnecessaryfor anycommercialQuickTimeencoding.TheProencodermakesfilesfullycompatiblewiththe bundleddecoder—nouserupgradeisrequiredtoviewthefiles. SorensonVideo3Prooptions SorensonVideo3hasbeenincludedwithQuickTimesinceversion5.0.2,whichshippedinthe summerof2001. •QuickCompressThisoptionslightlyspeedsuptheencoderattheexpenseofslightlyreducing quality.Becauseneithereffectissignificant,youcanalmostalwaysleavethisoptiondeselected. •BidirectionalPredictionTouseB-frameencodinginSorensonVideo3andaddcompression efficiencyandscalability,choosethisoption.Withscalability,theB-framescandropifthe processorisn’tfastenoughtoplaybackalloftheframesorifthedatarateisn’tsufficientto streamalltheframesbymeansofRTSP.Thisoptionautomaticallydropsframesandreduces
CompressionPrimer
39
CPUrequirementsbyatleast50%andreducesdataratebyabout25%,atthecostofcutting theframerateinhalf.ThisoptionisespeciallyusefulinstreamingbecausewithoutB-frames, theserverdropsallframesexceptthekeyframeswhenunderbandwidthstress. So,itwouldbegreattousebidirectionalpredictioninallcases.However,thereisoneproblem withB-frames—theycausevideotobedelayedtwoframesrelativetoaudio.At29.97fps,this delayisonlymildlydistracting,butatlowerframerates,thevideocanappeardubbed.Also, B-framescansometimescauseinstabilityinversionsprevioustoQuickTime5(thisproblem appeartohavebeenfixedinQuickTime6). ThereisanAppleScriptforMactofixthesyncinanalreadyencodedfile. •RateControlModeTheunlabeledratecontrolboxforthisoptionhasthreeadditional options.TheoptionNeitherFeatureperformsastandardCBRencode. TheSorensonOne-PassVBRoptionloosensupthedatarate.Thisistheoptimalmodefor encodingforRTSPandformostnon-RTSPencodedfileswherepeakdatarateisn’taconcern. NotethatiftheStreamingoptionisselected,theVBRwindowisconstrainedtotheappropriatevalueforstreaming. TheMinimumQualityoptionsetsaminimumqualitythresholdforeachframeonthe0-100 scale.IftheDropFramesToMaintainDataRateoptionisselected,theframerateisreduced whenthequalitythresholdisexceeded,andthedatarateismaintained.Ifthisoptionisnot selected,thedatarateriseswhentheminimumqualityisn’tmet,meaningthatthefinaldata rateisovershot. •ImageSmoothingThisoptionactivatesadeblockingfilter,whichimprovesthequalitywhenit wouldotherwisebeblocky.Itdoesn’thavemucheffectathigherdatarates,anditisautomaticallydeactivatedonplaybackifthecomputerisn’tfastenoughtoruntheoperation.Generally,youshouldactivateit. •MediaKeyTheMediaKeyoptionassignsapasswordtothevideothattheplayerapplication needstoprovideforthevideotoplayback. •StreamingYoushouldselectthisoptionforallfilesthatwillbeRTSPstreamed.Thedefault settingsareappropriateformostprojects. Don’tmodifytheSlicePictureIntoPacketsOfBytesoption.Itneedstobemodifiedinsync withthehintingsettings,andexceptinsomeprivatenetworks,itisn’thelpedbyothervalues. TheForceBlockRefreshEveryoptionensuresthatevery16x16blockofthevideoisrefreshed atthespecifiedinterval.Thisrefreshhelpswitherrorrecovery(anyglitchfromadropped pocketiserasedatleastthatoften).Byusingthisoption,youcanlowerthenumberof keyframesinthefile.Thisoptionslightlyreducescompressionefficiencywithstaticimages (whichisn’tasimportant),butitdoesn’thavemuchofanimpactwithfastmotion(where blocksarenaturallyrefreshedbymotion). •MaskingUsethisoptiontoincludeareal-timealphachannelinthevideo.Thecodeccan eitheruseaprovidedalphachannel,oritcangenerateoneitselfbasedonaninternalchromakeyer.Theinternalkeyerislimited,sousingaprofessionaltoollikeAdobeAfterEffectsto generatethealphachannelcanofferyoumuchbetterresults.Touseanalphachannelinthe sourcefiles,youneedtosetthecolortoMillions+. CompressionPrimer
40
•WatermarkingSV3.1ProIfyouwanttoaddareal-timecompositedwatermarktothevideo, usethisoption.Thiswatermarkcanprovidemuchhigherqualitythanaddingawatermarkto thevideosourcebecausethefinedetailsofasourcewatermarkareoftenlostincompression. Thewatermarkcanhaveopacity,oritcanbecolored.Notethefileformatforthewatermark isveryfinicky—carefullyreadthesectioninthecodecmanualdescribinghowtomakethe file.IfyouusePhotoshoptoconvertanalphachanneltoaSorensonwatermark,agoodstartingpointistoapplytheexistingalphachanneltoa50%graybackgroundandthenflattenthe image.Notethatthecolorthecodecusestokeythetransparencyisintheupperrightcorner. SorensonVideocodec QuickTimealsoincludestheolderSorensonVideo(nonumberislisted,butit’sversion2) codec.ThiscodecisacompletelydifferentcodecthanthecurrentSorensonVideo3becauseit haslowercompressionefficiencyandquality.Youcanuseitifyourequirecompatibilitywith versionsofQuickTimepriortoversion5. TherewasanupgradeoftheoriginalSorensonVideocodeccalledSorensonVideo2.2DeveloperEdition,butitisnolongercommerciallyavailable. MPEG-4codec QuickTimeincludesaMPEG-4codec.ThiscodecisavailablebydefaulttoallMacOSencoders. However,itisonlyavailableonafewWindowsencodersthathavepaidalicensefeetoenableit. QuickTimesupportstheSimpleVisualspecificationforplayback,andyoucanusethird-party MPEG-4encoderstomakeafilethatplaysbackwithinQuickTime.Third-partyencodersgenerallyofferbettercompressionefficiency,withtechniqueslike2-passVBRencoding. SorensonVideo3.1ProoffersbettercompressionefficiencythanMPEG-4andbetterstreaming performance.ThebiggestadvantageofMPEG-4inaQuickTimefileisthedecoderspeed,which isfasterthanSorensonVideo3’s. MPEG-4hasbeenincludedinQuickTimesinceQuickTime6,whichshippedsummerof2002. H.263codec H.263isastandardvideoconferencingcodecthathasbeenincludedwithQuickTimesince QuickTime4.Itstreamswellandprovidesgoodstreamingperformance.Itcan(rarely)beatthe freeversionofSorensonVideo3forstreaming,butitisn’tasgoodasSorensonVideo3.1Pro. OneuniquefeatureofH.263isthatitonlyinternallyusesthethreelistedresolutions.Ifadifferentresolutionispicked,itusesthenextsmallestresolutioninternally,andscalesthevideo tothecorrectresolutioninreal-time.Ifdesired,youcanassignthespecificresolutionhere,but thisassignmentisn’tneededinmostcases. TheCycleIntraMacroblocksfeatureperformsasimilarfunctiontoSorensonVideo3’sBlock Refreshandimprovesstreamingperformance,especiallyinlossynetworks.Itshouldbeactive onlyforRTSPfiles. Cinepakcodec CinepakwasthedominantCD-ROMcodecformostofthe1990s.Ithasbeenincludedin QuickTimesinceversion1.5overadecadeago.Cinepak’shallmarkwasaveryfastdecoder— videoat320x240playedbackwellon60MHzcomputers.Still,thesimplicityoftheencoder resultsincompressionefficiencywellbelowthatofmoderncodecs.Cinepakisoneofthefew deliverycodecsthatsupportsanativegrayscalemode,whichgivesfasterdecodeperformance withblack-and-whitesources.
CompressionPrimer
41
ThemainuseofCinepakthesedaysisforhigh-resolutionplaybackonold,slowcomputers,like thoseoftenseeninK-12schools.Avideoat640x480and29.97fpscanplaywithoutahitchon afiveyearoldcomputeralbeitatdataratesofatleast5000Kbps. VP3codec On2/TheDuckCorporationhasbeenmakingcommercialcodecsforadecade.Theirmore recentVP5andVP6codecsaren’tavailableincommercialproducts,buttheVP3codecis opensourcedandisfreelyavailableforQuickTime.Whileitisn’tpartofthestandardinstall, it’savailablethroughcomponentdownload,whichmeansQuickTimeautomaticallyoffersto downloadthecodecwhenitdetectscontentthatusesit.Toforceaninstall,runtheQuickTime Updaterutility—theVP3codecisoneofthethird-partyoptions. TheVP3codecdoesn’thaveanativepacketizer,soitisn’tanappropriatetoolforRTSPstreaming.Also,theVP3codecisseveralyearsoldandhascompressionefficiencybelowthatof SorensonVideo3.3Pro,andalsohasunpredictabledatarates,soitisn’tagoodfitforwebdistribution.However,thedecoderisfasterthanSorensonVideo3,makingtheVP3codecaviable optionforhigh-resolutionCD-ROMandkioskwork. BecausetheVP3codecisopensourced,differentimplementationsvary.Forexample,the DirectShowversionofthecodecformakingAVIfilesonWindowshasafewoptionsthataren’t currentlyavailableintheMacOSencoder,althoughtheMacOSplayercanplayfilesencoded withthosefeatures. TheAllowDroppedFramesoptionintheVP3codecinstructstheencodertodropframesto maintaindatarate.TheVP3codechasafairlyhighminimumquality,sowhenthisoptionis notselected,thetargetdataratemightbesubstantiallyexceeded.Still,droppedframesaredistracting,sotheVP3codecisn’tthebestonetouseforhighcompressionefficiency. TheQuickCompressmodesubstantiallyspeedsuptheencodewithonlyaminimumhitin quality.Unlikeothercodecs,it’ssafetoruntheVP3codecinQuickCompressmodebydefault. Still,ifthetimeisavailable,encodingwiththismodeinactiveguaranteesthebestqualityand mostaccuratedataratespossible. VP3hasamorecomplexkeyframeinsertionmodethanmostcodecs.Notonlycanyouseta threshold,butyoucanspecifytheminimumandmaximumnumberofkeyframes.Thedefault settingsforThresholdandMinimumworkwellformostprojects.Ifyourvideoincludesvery fastediting,youmightwanttosetalowerminimum,andifyou’reworkingwithveryhigh framerates,youcansetahighermaximum.Makesurethatthekeyframeratesetintheencodingapplicationoutsideofthisdialogboxisgreaterthanthemaximumnumberofframes. Animationcodec Apple’sAnimationcodecisaninterframeRun-LengthEncoded(RLE)RGBcodec.Hence, forgoodcompressionefficiency,itreliesonlonghorizontallinesofexactlythesamecolorfor eachframe.TheAnimationcodecdoesn’thaveanydataratecontrol;itonlyhasqualitysliders. Hence,it’snotappropriateforencodingvideooriginatedasnaturalimageswheretwoadjoining pixelsarerarelyidentical.Itcandoagoodjobwithrecordedscreencaptures,althoughthereare someworkflowtricksrequiredtodothosewell,whichareoutsidethescopeofthisdocument. TheAnimationcodecislosslesswhenthequalitysliderisat100%.Atlowerlevels,itsimply makeshorizontallinesthatarealmostidenticalactuallyidentical.Thisprocesscanproduce poorqualitywithmanysources,whichresultsinvisiblebanding.Notethatdespitethename, CompressionPrimer
42
theAnimationcodecisn’tverygoodatencodingthree-dimensionaloptimization,wherelightingeffectspreventregionsofidenticalpixels. YoucanalsousetheAnimationcodectostoreintermediatefilesamongfiles.TheAnimationcodecstoresintermediatefileswellwhenusinganRGBworkflowwithRGBnativetools, likeAfterEffects,especiallywithsyntheticimages.However,thedataratestheAnimation codecproducesarebarelybetterthanuncompresseddataratesfornaturalimages.Also,some compressiontoolsdon’tworkwellwithinterframeencodedfiles,soyoushoulduseakeyframe ineveryframeinthosecases.ThePortableNetworkGraphics(PNG)andMicrocosmcodecs providebettercompressionwithidenticalqualityinthosecases. Graphicscodec TheGraphicscodecisalosslessRGBcodec,liketheAnimationcodec.It’sdifferentbecauseit offersbettercompressionefficiency,butitonlyworksin8-bitcolor.Itdeliversscreenrecordings well,butonlyifyouconvertthefileto8-bitfirst,whichisatrickyprocess. PNGcodec PNGisanRGB-onlycodecthatwasoriginallydevelopedasapatent-freealternativetotheGIF format.However,itevolvedtohavebettercompressionefficiencyandsupportformorethan 8-bitindexcolor.Itisveryefficientatencodingsyntheticcontentwithareasofflatcolor,like screenshots.Itisn’tusefulasadeliverycodecformovingvideobecauseitisinterframeonly, anditdoesn’thaveadataratecontrolmode.PNGsupportstheMillions+mode,soitcantransportanalphachannel. PNG’sinterlacedmodeisn’tforinterlacedfields;instead,youuseitforprogressivedecoding oftheimage.Whenyouchoosethisoption,theimageinitiallyshowsalowerresolutionproxy whileitdownloads.Thiscodecdoesnotworkwellforarchivingbecauseitslightlyreduces compressionefficiency. PNGisalwayslossless,buttheFiltermodecontrolsthetrade-offbetweenencodingtimeand finalfilesize.Formaximumcompressionefficiency,usetheBestoption.Formaximumspeed whilestillgettingsomecompression,usetheUpoption. Microcosmcodec TheMicrocosmcodecisanotherlosslessRGBinterframe-onlycodec.Itsbigadvantageover PNGisitssupportfor16bitsperchannel,sothiscodeccanlosslesslyarchivecontentwhenyou useitwithtoolsthatsupport16bitsperchannel,likeAfterEffects.This16-bitsupportreally excelswhendeliveringtofilmorbroadcast,especiallywhenworkingwithCineonorasource withmorethan8bitspersource.TheMicrocosmcodeccanalsotransportanalphachannel. AfreedecoderfortheMicrocosmcodecisavailablethroughcomponentdownload,butyou needtopurchasetheencoder. None16codec None16isafreecodecfromthecreatorsofMicrocosm.Itoffers16-bit-per-channelRGBandan alphachannel.However,itisfullyuncompressed,sothefilesizesarehuge. Photo-JPEGcodec Photo-JPEGisacodecimplementationofthestandardJPEGstillphotographycodec.It’salossy codecthatsupports8-bit-per-channel4:2:0Y'CbCr,orgrayscale;however,itisvisuallylossless atqualitysettingsabove85formostcontent(Photo-JPEGlacksanexplicitdataratecontrol). CompressionPrimer
43
Photo-JPEGcanbeagoodwaytodelivercontentforslideshows,butMotionJPEGismore suitableformostvideoarchivingandtransportuses.Photo-JPEGdoesn’trecognizefields,soit worksbestwithprogressivecontent. MotionJPEGcodec MotionJPEGisa4:2:2varietyofJPEGwithsupportforfields.It’sthenativeformatofmany NLEsystems;manyofwhichcanlosslesslytranscodefromtheirownnativeformattothe genericQuickTimeMotionJPEGcodecs. TherearetwotypesofMotionJPEGcodecs:AandB.Theseoriginallycorrespondedtodifferent chipsetssupportedbyearlyNLEcards.They’refunctionallyequivalent;soit’sprobablyeasiest todefaulttousingA.Youneedtomanuallysetthecorrectfieldmodeandfielddominance (whichisfieldordermislabeled)intheOptionsdialogbox. Componentcodec TheComponentcodecisanuncompressedY’CbCr8-bit-per-channel4:2:2codec.Becauseit’s uncompressed,itisextremelyfast,butdataraterequirementscanbesubstantial.Itismainly usedasanintermediateformatforuserswithalotofcomputerdrivespace.TheComponent codecdoesnotsupportanalphachannel. Nonecodec TheNonecodecisauncompressedRGB.ItoffersalloftheRGBQuickTimecolordepths, includingalphachannels,exceptfor16-bit-per-channelmodes.Unlessyouneedpurespeed,you rarelyneedtousetheNonecodec,giventhevarietyoflosslessRGBcodecsinQuickTime.
QuickTimeaudiocodecs QuickTimeaudiocodecsdon’thaveaspecificdataratecontrolintheirmainuserinterface. Instead,yousetthedatarate,ifcontrollable,intheOptionsdialogbox. MPEG-4codec ThebestgeneralpurposeaudiocodecinQuickTimetodayisMPEG-4AAC-LC.Encodingis onlyincludedbydefaultonMacOS.Windowsusersdon’thaveaccesstothiscodecinmost applications.TheMPEG-4codeclistsoptionsforAAC-LC(ageneralpurposecodec)andCode ExcitedLinearPrediction(CELP),usedforlow-bit-ratespeech.CELPisn’tactuallyavailable afterQuickTime6.5. LikeMPEG-4video,MPEG-4audioisbasedontheopenMPEG-4standard.Youcanusea third-partyAAC-LCencodertomakeafilethatyoucanimportintoQuickTimeanduseasa videotrack.MPEG-4hasanativepacketizerandworkswellforbothreal-timestreamingand file-baseddelivery. AAC-LCisaveryefficientmoderncodec.Dataratesabove128Kbps,evenfor48-KHzstereo, areoverkillformostcontent;musicisgoodenoughtodancetoat48Kbpsand44.1KHzmono, andsometimesbelowthosemeasurements. Theoptionlistedinboldistherecommendedoptionforoptimalquality—generallychoose thisoption.TheoptionsavailabledependonwhetheryouselectedmonoorstereointheMain AudioExportdialogbox—monogivesyouhighersamplerateoptionsatlowerdatarates. NotethatthecodecautomaticallyconvertsfromthesampleratespecifiedintheAudiodialog boxtotheratespecifiedintheCodecdialogbox.IfencodingtoAAC-LCateither44.1or48, setthesamplerateintheAudiodialogboxtomatch.Ifusingalowersamplerate,setthesample CompressionPrimer
44
rateintheSourcedialogboxtomatchthatofthesource(generally48KHz).Avoiddoingtwo samplerateconversions. TheEncoderQualityoptionsetsthequalityandspeedtrade-offforthecodec.Fora16-bit source,Betteristheappropriatedefault.Bestonlyhelpswithsourcesmorethan16-bitandis slowerthanBetter. QDesignMusic2codec QDesignMusic2(QDM2)wastheleadingstreamingaudiocodecbeforeQuickTime6and MPEG-4.ItremainsthebestcodecavailablebydefaultinQuickTimeforWindows. TheQDM2 codechasanativepacketizeranditisafineoptionforstreaming. QDM2doesverywellwithinstrumentalmusic,butitcanhaveobjectionableartifactswhen encodingspeech,evenathigherdatarates.Ifitcreatesartifacts,tryreducingchannelsfromstereotomono,andthentryreducingthesamplerate.TheProversionanddataratesgreaterthan 48Kbpsarerequiredtocompress44.1stereowithmixedcontent.ThefreeversionofQDM2is limitedto48Kbpsmaximumdatarate. QDesignMusic2Procodec TheProversionofQDM2offersbettercompressionefficiency,muchfasterencodingspeeds, anddataratesgreaterthan48Kbps.ThebasicversionofQDM2supports8-48Kbps.ThePro versioncancompressupto128Kbps. Thiscodecincludessuggestedsamplerateandchannelcombinations.Thesesuggestionswork wellforinstrumentalmusicbutareoverlyaggressiveforcontentcontainingvoices.Youcanuse thecodecineitherQualityorSpeedmode.TheProversionismuchfasterthantheBasicversion,andsoyoushouldusetheQualitymode. Formostcontent,youcanusethedefaultAttackandSpreadsettingsof50/50.Ifthecontentis compressingwithalotofartifacts,tweakingthesesettingsonatrial-and-errorbasiscansometimesyieldbetterresults. QualcommPureVoicecodec QualcommPureVoiceisthecodecthatCodeDivisionMultipleAccess(CDMA)cellphonesuse, anditsoundsalotlikeacellularphone.Thiscodecisquiteintelligiblewithspeech,butithas difficultywithothertypesofcontent.ThePureVoicecodecsupportsmonoaudioonly. Thecodecworksbestat8KHz,especiallywithreal-timestreaming.Ifyouhavesufficientdata ratetorunitat22KHzorgreater,adifferentcodecwouldlikelyprovideabetteroverallexperience. PureVoicehasanativepacketizer,soitisafinestreamingcodec.Thepacketizerworksbestat8 KHz,soyoushouldusethatsamplerateforstreamingprojects. TheQualcommPureVoicecodechastwomodes.FullRatemodeoffersa9:1compressionover pulsecodemodulation(PCM),so8KHzisaround15Kbps.Qualityissimilartoacellphone withagoodconnection.HalfRatemodeoffersa19:1compressionoverPCM,soabout7.5Kbps at8KHz.Whilespeechshouldbeintelligible,qualityisnoticeablydegradedfromtheFullRate mode.Thequalityissimilartoacellphonewithaweakconnection. TheOptimizeCompressionForStreamingoptioninstructsthehinternottotransmitblank dataineachaudioblockwhenstreaming.Thisoptioncansomewhatreducereal-worlddata rates,butitperformsthisreductionunpredictably.YoushouldactivateitonlyforRTSP. CompressionPrimer
45
IMAcodec IMAisanoldCD-ROMcodeccreatedbytheInteractiveMultimediaAssociation.Itoffersa 4:1compressionovertheNonemode.Qualityisgoodat44.1KHz,butitlessensatlowerlevels. IMAisusefulbecauseofitsveryfastdecoderandwidecompatibility(rangingbacktoQuickTime2.1anditworksinAVIaswell).ItisadecentoptionforCD-ROMandkioskuseswhere playbackperformanceismoreimportantthancompressionefficiency. QuickTimealsosupportstheIMAAdaptiveDifferentialPulseCodeModulation(ADPCM) variantcreatedbyMicrosoft.It’seffectivelythesamecodec,butitismorecompatiblewitholder AVIplayers. MP3codec WhileQuickTimedoesn’tincludeitsownMP3encoder,ithasaverycapableMP3decoder,and itcanplayMP3filesencodedbyawidevarietyoftools.SomeencodingtoolshavenativesupportforencodingMP3asanaudiotrack. AgoodMP3encoderoffersbetterperformanceformixedcontentthananyotherQuickTime codec,otherthanMPEG-4.Qualityisquitegoodat128Kbpsfor44.1stereo,andcompression istransparentformostlistenersat160Kbps. QuickTime4.1andlatercanhandleVBRMP3justfine.However,itcrasheswithQuickTime 4.0,soyoushoulduseCBRonlyifyourequirecompatibilitywithQuickTime4.0. AlthoughthereisanofficialRTSPmodeforMP3,QuickTimedoesn’tsupportit.Youshouldn’t useMP3forRTSPstreaming. Nonecodec TheNonecodecisanuncompressedPCMaudiotrack.Itisrarelyappropriateforadelivery codec,butitisthebestoptionforintermediateandtransportuse.TheNonecodecsupports8 bitand16bit,butyoushouldonlyuse16bit. 24-and32-bitintegercodecs QuickTimealsosupportsPCMinthehighersampledepthsof24and32bit.Thesecodecsare fortransportingbetweentwotoolsthatsupportthesehighersamplerates. FloatingPointcodecs Thefloatingpointcodecsareoccasionallyusedtoexportaudiotosomehigh-endaudioor signalprocessingtools.Youwouldn’tusetheseinanormalworkflow. MACEcodec MacintoshAudioCompressionEngine(MACE)isa1980spre-QuickTimeaudiocodecwith verypoor8-bitquality.
ExportingtoMPEG-1format MPEG-1wasthefirstopenmultimediastandard.TheoriginalvisionforMPEG-1forcomputerswasthatuserswouldbuyadd-onMPEG-1decoderboardsfortheircomputersforplayback. However,thisvisiondidn’tbecomepopular,soMPEG-1playbackdidn’thappenwidelyuntil computersbecamefastenoughtoperformallofthedecodinginsoftware. VideoCD,aprecursortoDVD,alsousedMPEG-1.Whileitdidn’tgetusedmuchelsewherein theworld,VideoCDbecameenormouslypopularinAsia. MP3wasalsoatechnologyspin-offfromMPEG-1. CompressionPrimer
46
UsingMPEG-1forprogressivedownload Althoughitscompressionefficiencymayonlybehalfthatoftoday’scuttingedgewebcodecs, MPEG-1stillplaysaroleinprogressivedownloadswherevastcompatibilityismoreimportant thancompressionefficiency. MPEG-1dataratesarehigherthanotherformats.Agoodoptionis256x192videoat336Kbps coupledwith64-Kbps,32-KHzmonoaudio.Thatdatarateproducesdecentqualitywithlotsof contentwhencoupledwithagood2-passVBRMPEG-1encoder.MPEG-1forthewebshould alwaysbesquarepixel. UsingMPEG-1forreal-timestreaming MPEG-1reasonablysupportsreal-timestreamingandincludesbuilt-insupportinApple’sfree DarwinStreamingServerandinavarietyofproductsfromCisco.NotethecompressionefficiencyofMPEG-1isnotashighasothermoderncodecs. UsingMPEG-1forCD-ROMdelivery MPEG-1isoftenusedforCD-ROMwork,wheredecodeperformanceandcompatibilityismore importantthancompressionefficiency,especiallyforcross-platformCD-ROMprojectswhere itisn’tpossibletoinstallQuickTime.MPEG-1istheonlygoodcross-platformfileformatfor PowerPoint,whichcan’teasilyuseQuickTimefilesonWindowsorWindowsMediaonMac. MPEG-1encodedforCD-ROMshouldbeencodedinsquarepixelbecauseolderversionsof MicrosoftDirectShowhandlenonsquarepixelsincorrectly. UsingMPEG-1forVideoCDdelivery TheVideoCDformatismainlypopularinAsia,butit’salsoplayableonmostpersonalcomputerswithoutadditionalsoftwareandinDVDplayers. NotethatVideoCDs,likeDVDs,comeinPALorNTSCplayers.Acomputercanplaybothformats,butaset-topDVDorVCDplayermayonlyplaydiscsinitsownformat. VideoCDhasaverytightlyconstrainedsetofparameters.Resolutionis352x240inNTSCand 352x288inPAL,anddatarateisalsolockeddown.PALisalways25fpsandNTSCcaneither be29.97fpsforvideoor23.976fpsforfilmsources.ThedatarateislockeddowntoaCBRrate exactlythatofanaudioCD,soforeveryminuteofaudioaCDcanhold,itcanholdoneminute ofVideoCDvideo. NotethatyoucanmakeVideoCDonCD-R,butCD-RVideoCDdoesn’tworkonsomeearly modelDVDplayersduetoanincompatibilitywiththelaser.ManufacturedCD-ROMmedia worksfine. TherearemanyVideoCDsinuse,eitherolderdiscsordiscsencodedwithacheapreal-timeor softwareencoder.Modernprofessionalgradeencoderscanbequitegood.Sowhiletheresolutionmightbelow,theimageandsoundqualitycancomeoutnicelywithavarietyofcontent.
MPEG-1videoandaudiocodec MPEG-1onlysupportsonevideocodec,alsocalledMPEG-1.Thiscodecalsoincludesthree audiomodes:LayerI,LayerII,andLayerIII. MPEG-1codec(forvideo) MPEG-1offeredincrediblecompressionefficiencyforitsday,andmodernencoderscanperformwellatdataratesfarbelowthedataratestheformat’screatorsthoughtpossible.MPEG-1’s biggestbarrierforuseisthatitlackspostprocessing,soatlowdatarates,itgetsblockyinsteadof
CompressionPrimer
47
soft,whichresultsinarelativelyhighminimumbitratefordecentresults.2-passVBRsubstantiallyhelpsMPEG-1andisavailableinmostimplementations. MPEG-1codec(foraudio) Inpractice,onlytheLayerIIaudiomodeisused.LayerIhadlowercompressionefficiency. LayerIIIneverbecamestandardaspartofthedecoders.However,itcontinuestoliveunderthe nameofMP3. LayerIIofferscompressionefficiencyabout50%lessthanMP3.VideoCDuses224Kbps,and generallysoundsquitegood.UsinglowerKbpsvaluescanalsoworkwellforwebcontent. LayerIIsupportsjointstereo,whichimprovescompressionefficiency,especiallyatlowerdata rates.MostLayerIIencodersdon’tdefaulttohavingjointstereoactivated,soyoumayneedto setthismanually.UsejointstereounlessyouneedtopreserveDolbyProLogicsurroundsound encoding.
ExportingtoDVDandMPEG-2formats Measuredineyeball-hours,MPEG-2iseasilythedominantdigital-videoformatworldwide.It’s usedinvirtuallyalldigitalbroadcastsystems(digitalcable,satellite,andbroadcast),aswellas DVD. OnegreatstrengthofMPEG-2isthewayithandlesprogressiveandinterlacedcontent.Entire streamscanbeinterlacedorprogressive.Interlacedstreamscanhaveprogressiveframesin them,andinterlacedframescanhaveprogressiveblocksinthem.Notethat,dependingonthe player,interlacedMPEG-2filesmayormaynotbedeinterlacedwhenplayedbackoncomputers. TheDVDformat’sMPEG-2subsetdoesn’tactuallysupportprogressivestreams.Telecinedfilm onNTSCDVDisstoredwiththeusual3:2pulldownpattern.However,bymarkingtheframes thatareprogressiveandthosethatareinterlaced,andbyusing“fieldrepeat”tagsthatindicate the12fieldseverysecondthatareduplicates,youcanuseprogressiveDVDplayerstoperform areal-timeinversetelecineandrestorethevideoto23.976fps.Whenyouattachaprogressive DVDplayertoaprogressivedisplay,thevideocanplaybackatthenativeframerate,which improvesimagequalityandsmoothness. GoodMPEG-2encodersautomaticallytake23.976por24psourceandmakeacorrect“progressive”DVDoutofit. UsingMPEG-2forDVDdelivery DVDsusetheMPEG-2videocodec,buttheydon’tusetheMPEG-2fileformat.Instead,they useaVOB(VideoObject)file,whichusesotheraudiocodecsandincludesothertypesofinformation,suchassubtitles. Manycompressiontoolscan’tdirectlyexportaVOBfile.Togetaroundthislimitation,youcan produceanMPEG-2videofile(calledanelementary)stream(generallyM2V)andastand-alone audiofile(WAVorAC3),andthenuseanauthoringtooltocombinethemintoaVOBfile. UsingMPEG-2forCD-ROM/DVD-ROMdelivery MPEG-2hasn’tbecomeaviabledisc-basedplaybackstandardbecausedecodersaren’tbundled withallpersonalcomputers,andyoucan’tlegallydistributethemwithoutpayingasignificant licensingfee. Forkioskapplications,MPEG-2canworkwell.Ithaslowerprocessorrequirementsperpixel CompressionPrimer
48
thanmanyotherformats,soifdiscspaceisn’taconcern,youcanuseMPEG-2quitenicelyto playbackhigh-resolution,high-qualityvideo. WorkingwithGOPsonDVD ForDVD,thestandardgroupofpictures(GOP)sizeforPALandtelecinedfilmcontentis12, andNTSCuses15.Thestandardallows15forthemaximumPALand18forthemaximum NTSC. GOPscanbeeitheropenorclosed.InanopenGOP,thelastB-framesoftheGOPcanuse thenextI-frameforreference.TheabilitytousethenextI-framegivesasmall,butwelcome, improvementincompressionefficiency,butitmakesrandomaccessalittlemorecomplex becauseeachGOPisnotwhollyself-contained. ForDVDauthoring,OpenGOPisfineexceptformultiangletitles.MultiangletitlesneedClosed GOPsandneedtohavealltheI-framesalignamongtheanglestoprovidesmoothswitching amongangles.
MPEG-2audiocodecs WhiletherearedefaultMPEG-2audiocodecs,mostimplementationsuseothercodecs. LayerIIaudiocodec Thetheoreticallystandardaudiocodecusedinstand-aloneMPEG-2filesisLayerII,thesameas MPEG-1.TheAACaudiocodecthatMPEG-4usesalsooriginatedasanMPEG-2codec,butit isvirtuallyunusedinMPEG-2files.InanMPGorMP2fileusedforcomputer-basedplayback, LayerIIistheonlyaudiocodecused. However,DVDsdon’tuseLayerII;theyuseotheraudiocodecsthatarenotpartoftheofficial MPEG-2specification. PCMcodec ConsumerDVDauthoringpackagesuseuncompressedPCMaudio.Thequalityisflawless,but thedataratesarehigh.Foraone-hourhomevideo,qualityisnotanissue,butwhenyoutryto addalotofcontentonasingledisc,theDolbyDigitalcompressionefficiencyallowsyoutoadd morehigh-qualityvideotoasingledisc. YoucanusePCMforhighsampleratesandchannels,butitisalmostonlyeverusedat48-KHz 16-bitstereo. DolbyDigitalcodec DolbyDigital,alsocalledAC-3,isthestandardforprofessionalDVDaudio.IncludingAC-3 encodingisthehallmarkofaprofessionalDVDauthoringtool. ThehistoricalstandardAC-3dataratewas384Kbps,buttheDVDstandardallowsfor448 Kbps.TheDVDstandardisbestformostmultichannelprojectsunlessdatarateisatanabsolute premium.Stereoencodingcanuseless—192Kbpsisgenerallysufficient. DTScodec Somehigh-endtitlesalsoincludetheDigitalTheaterSound(DTS)audioformat.DTSallows formuchhigherdatarates(althoughthesehigherratesarepartiallyduetolowercompression efficiency—DTSdoesn’tusepsychoacoustics).DTSisgenerallyonlyusedonA-listHollywood titles,forseveralreasons.First,themasteringtoolsarequiteexpensiveandarenotbundledwith compressiontools.Second,DTSdecodingisn’tmandatedaspartoftheDVDspecification,so CompressionPrimer
49
DTStitlesalsoincludeDolbyDigitaltracksaswell.HavingbothDTSandDolbyDigitaltrackscuts intoavailablediscspace,andtheaudioqualitygainsareslightatbestcomparedto448KbpsAC-3.
ExportingtoMPEG-4format MPEG-4isthefollow-upISOstandardtoMPEG-1andMPEG-2.Unlikethoseformats,which werecreatedbeforetheweberaandwerestrictlyfocusedonaudioandvideoplayback,MPEG-4is amuchbroaderandextensibleformat.Theformatisonlynowbecomingwellknown. Profilesandlevels Thereisnosimplethingcalled“MPEG-4compatibility.”TheMPEG-4standardhasamassive scope.Tomanagethesupportneedsofparticularproductsandindustries,itusestheconceptof profilesandlevels.Aprofiledefinesthefeaturesyoucanuse,likeB-frames.Aleveldefinesthe maximumparametersthatyoucanusewiththosefeatures,likemaximumframerate,framesize, ordatarate. Thefollowinglistcontainstheprofilesthathandlevideocompressionthataremostcommonly seen,oratleastdiscussed,forfutureimplementation.Notlistedaretherichmediaandother,more advanced,profilesthataremoreamatterofauthoringinsteadofcompression. •ShortHeaderThisprofileisthesameasabaselineH.263andisasubsetoftheSimpleVisualprofile.Sofar,ShortHeadermodeisonlyrequiredbysomecellphones.EvenatypicalPDAcanuse moreaggressiveprofiles.Still,ShortHeadercanprovidereasonablequalityatlowerdatarateson thesmallscreensthesedeviceshave. •SimpleVisualThisprofileisthecurrentbaselineforcomputerplaybackandisthehighestvideo profilesupportedbyQuickTime.ItprovidescompressionefficiencybetterthanH.263,butitis lessthancompetitiveagainstthecurrentgenerationofcodecs. •AdvancedSimpleThisprofileisanenhancedversionoftheSimpleVisualprofile,addingsupport forinterlacedvideo(athigherlevels),B-frames,andotherfactorsthatcanimprovecompression efficiency.MostcomputerplayerssupporttheAdvancedSimpleprofile,withtheexceptionof QuickTime. •SimpleScalableThisprofileisthemostbasicformofscalabilityforreal-timestreamingin MPEG-4.Simplescalablehasonlyoneenhancementlayer,andhence,twopossibledatarates.It hasbeenadoptedinPacketVideo’ssuiteoftoolsbutnotbeyondthat. •FineGrainScalabilityThisprofileprovidesrobustscalabilityforMPEG-4.Itcombinesmultiple enhancementlayersplustheabilitytouseonlypartofagivenlayertoprovideveryflexiblescalingthatisabletooptimizeitselfverytightlywiththeavailabledatarate. Unfortunately,noproductsuseityet.UntilFineGrainScalabilityorsimilarMasterBoot Record(MBR)technologyisimplemented,MPEG-4won’tbecompetitiveforreal-timestreamingovertheInternetcomparedtoWindowsMediaandRealMedia. •AVC(AdvancedVideoCoding)ThisprofileisthebignewthingintheMPEG-4world.Also knownasH.264,JVT,H.26L,andMPEG-4Part10,itisanewcodecbuiltfromthegroundup thatisnotbasedonH.263.ThehopeisAVCwillbeacodecthatlastsadecade,likeMPEG-2,so itsdesignemphasizescompressionefficiencyoverperformance. AttheNAB(NationalAssociationofBroadcasters)2003exhibition,developersfirstdemonstratedtheAVCencoders.Currently,AVCencodersareintheearlystagesandstartedappearing inproductsin2004.
CompressionPrimer
50
•StudioThisprofileismeantforstudiouse,likeI-frame-onlyMPEG-2,MotionJPEG,and proprietarycapturecodecsfrommanyvendors.UsingMPEG-4videotechnology,theStudio profileoffersmasteringqualityatlowerdataratesthantoday’sformats.Thisprofileincludes 10-bit-per-channelmode,4:2:2and4:4:4,andotherfeaturesdesirableinhigh-endvideo authoring. Therearen’tanyStudioprofileproductsyet,norareanyexpectedinthenearfeature.It remainstobeseenifthisprofilewillbecomeasignificantuseofMPEG-4.
DivX TheAVIcodecwiththemostbuzz thesedaysisDivX.Itdoesn’teven usethe.aviextension;instead,it uses.divx.DivXwasoriginallybased onanillegalhackoftheMicrosoftMPEG-4version3codec,but sinceversion4,ithasbeenbased onstandardscompliantMPEG-4 forvideo(SimpleinV4,Advanced SimpleinV5).
•N-BitThisprofileisforhigh-enduses,suchasarchivingmedicalimages.MPEG-4offersthe N-Bitprofilesthatallowencodingin16bitsperchannelandothermodes.N-Bitprofilesare usefulintheirowndomain,buttheyareunlikelytobeusedforcompressedvideodeliveryor evenvideoauthoring.
Foraudio,DivXnormallyusesMP3s. Toavoidconfusionwithallofthe other.avifilesoutthere,Divxhas adoptedthe.divxextensionforfiles, eventhoughthefileformatitselfis prettymuchaplainAVI.
•3GPPprofileThisprofile,whichstandsforThirdGenerationPartnershipProject,isdesigned formobilephones.Therearetwotypes,eachwithdifferentaudiocodecs.However,mostcarriersaremandatingacarrier-specifictypeof3GPP.Sofar,itisn’tpossibletomakeasinglefile thatwillworkonalltheMPEG-4playingmobilephones.Asthemobilephonesbecomemore powerful,thislimitationmaychange.
Thereasonit’snotconsidereda plainAVIisthatDivXfilesoftencontainVBRMP3audio,whereAVIhistoricallydidn’tsupportVBRaudio. Thissupporthasleadtoplayback glitchesonsomeplayers,especially QuickTime.
•ISMAprofilesThemostimportantgroupdoingworkforMPEG-4forweb-basedcomputer playbackistheInternetStreamingMediaAlliance(ISMA).TheypublishedtheISMA1.0 specificationinlate2001definingtwobasicprofiles(confusingly,notthesameasanMPEG-4 profile,butacombinationofMPEG-4profilesandlevel). ISMAProfile0Thisbasicprofileisdesignedforverylow-power mobiledevices,likecellphones.Sofar,thesekindsofdevicesare eitherusing3GPPoracarrier-specificformat. ISMAProfile1Thisbasicprofilewasoriginallydesignedforcomputer playback,butmodernXScale-basedPDAsarealsobecomingfast enoughtosupportit.Profile1istheonemostcommonlyquotedfor support.Unfortunately,manyplayersdon’tsupportthewholespecification.CELPsupportisonlyavailableinafewplayers. MPEG-4licensingissues Sofar,thebiggestbarriertowidespreadMPEG-4adoptionhasbeenlicensingissues.Thelicense termsaren’tprohibitive,buttheyweren’tfinalizedforalongtime,soconcernoccurredaround theambiguity. Mostformatsinvolvesomelicensefeestobuildencodersanddecoders,andMPEG-4isnodifferent.Productvendorspaythesecosts;theyaren’tanissueforthecompressionistordistributor.ButMPEG-4includesfeesfordistributingcontentintheMPEG-4format.Fordisc-based content,replicatorshavebeencollectingMPEG-2feesformakingDVDsforyears.Feesfor distributingcontentbymeansoftheInternetisnewforMPEG-4. Thesefeesaren’tasintimidatingastheysound—mostdistributorswon’thavetopayacent. First,thefeesonlyapplytorenumeratedcontent,notmarketing,advertising,andnoncommercialcontent.Forrenumeratedsites(mainlythosedoingsubscriptionoradd-fundedcontent), thefirst50,000subscribersperyearperlegalentityarefree.After50,000,thedistributorcan paytheirchoiceof$0.25persubscriberperyearor$0.02/hourofcontentstreamed.Thesenumbersareasmallportionofthebudgetofanystreamingproject.Still,thesimpleissueoftracking usehaslimitedadoptioninsomecases.
CompressionPrimer
51
MPEG-4audiocodecs AudioprofilesinMPEG-4combinesetsofpossiblecodecs.Becausemostimplementationssupportparticularcodecsinsteadofwholeprofiles,it’sgenerallymoreusefultodescribetheaudio codecsinsteadofprofiles. AAC-LCcodec TheaudiocodecusedinmostMPEG-4implementationssofarisAdvancedAudioCoding-Low Complexity(AAC-LC).The“LowComplexity”aspectisaveryhigh-qualitycodec.Whilethere areothertypesofAAC,onlyonehasshownsignificantlybettercompressionefficiencythan AAC-LCinlisteningtests. TheISMAstandardsincludeAAC-LC,andeverycomputer-basedMPEG-4playersupportsit. HE-AACcodec ThenewvariantofAACisHE-AAC(theHEstandsforHighEfficiency).HE-AACusesatechnologycalledspectralbandreplication,whichisessentiallyaveryefficientenhancementlayer. Currently,HE-AACisthebestaudiocodecbyafairmargin.Listeningtestsdemonstratenear transparencycomparedtoCDat48Kbpsandentertainmentqualityat32Kbps.HE-AAChas yettobecomemainstream,althoughitisexpected. CELPcodec CELPisalow-bit-ratespeechcodec.Duetolicensingissues,ithasn’tbeendeployedinenough playerstoreachcriticalmass,soitisn’twidelyused.Likeothersimilarcodecs,itprovidesintelligiblespeechatlowdatarates.ThereareseveralotherspeechcodecsinMPEG-4,butCELP isthemostfrequentlyusedcodec.AspeechcodecisnotneededasmuchinMPEG-4because AAC-LCperformswellwithlow-bit-ratespeech. AMRcodec TheonlyotherspeechcodecthatmattersinMPEG-4isAdaptiveMultiRate(AMR).LikeCELP, it’salow-bit-ratespeechcodec.UnlikeCELP,AMRsupportsreal-timescalability.AMRis mainlyusedinthe3GPPprofilesforcellphones.
ExportingtoAVIformat TheMicrosoftAudioVideoInterleaveformatwasaveryearlyformatforCD-ROM,anditisstill widelyusedinavarietyofapplications. UsingAVIforwebdelivery AVIisnotagoodwebformatbecauseitdoesn’tsupportreal-timestreaming.Also,thesetof codecsthatareavailablebydefaultonallcomputersisrelativelylimited.AVIfilesontheweb arealmostalwaysdistributedascompletefiles. UsingAVIfordisc-baseddelivery AVIisstillstrongfordisc-basedplayback.It’swellsupportedinapplications,suchasDirector, andbecausecodecscanbedeliveredwithadisc,installationsaremuchlessofaworry.
AVIvideocodecs TherearemanycodecsavailableforAVI.Mostofthemrequiremanualinstallation.Thefollowinglistcontainsafewofthemostcommonandusefulcodecs. Cinepakcodec TheclassicAVIcodecwasCinepak.AspreviouslydescribedintheQuickTimesection,Cinepak CompressionPrimer
52
offerslimitedqualitybutbroadplaybackcompatibilityandveryfastdecoderperformance. CinepakistheonlyvideocodecthatyoucanassumeisavailabletoallAVIplayers. Indeocodec Intel®createdtheIndeocodecs,butLigos®nowownsthem.Indeo3,4,and5wereverypopular intheCD-ROMera.However,theyhaven’tbeenmeaningfullyupdatedinyears.Theyusedto begooddefaultcodecs,butIndeoplaybackisn’tpreinstalledinWindowsXPanymorenorisit availableforMacOSX.TheIndeo3,4,and5qualitywaspoorerthanmoderncodecs,especially becausetheyusedtheYUV-9colorspace,whichonlyhadonechromasampleper4x4block. VP3codec AspreviouslydescribedintheQuickTimesection,VP3isanopensourcecodecoriginallycreatedbyOn2.Freeencodersanddecodersareavailableforitinavarietyofplatforms,althoughit isnotpreinstalledonWindowsorMac.(AVIplaybackofVP3filesworksbymeansofQuickTime,whichincludesVP3initsautomaticcomponentdownloadprogram.) ThecurrentversionoftheVP3codechasafewfeaturesnotavailableintheQuickTimeversion. TheLowestAllowedQualitycontrolsetsaminimumthresholdforquality.Tomaintaindata rate,youshouldusetheminimumvalueof63. TheSharpnesscontrolsetsatargetforwhethera frameshouldhavehighdetailbutcontainpotentialartifacts,besoftbutcontainnoartifacts,or beinthemiddle.Thebestchoiceisspecifictothesourceandhowit’sused. VP5/VP6codecs ThesenewcodecsarealsofromOn2andarebuiltonVP3withmuchimprovedcompression efficiency,especiallyinVP6.Theyareavailableasafreedownloadforpersonalusefrom www.on2.com. DivXcodec Asdescribedinthesidebar,DivXcodecshadanignominiousbeginningbuthaveevolvedinto animportantpartoftheAVIinfrastructure.Today’sDivX5isagoodimplementationofthe MPEG-4videocodec,supportingeitheraSimpleorAdvancedSimpleprofile. TheDivXcodecalsocontainsanumberofpreprocessingfeaturesinsidethecodecitself,which canbeusefulifyouareexportingwithatoolthatlacksthosefeatures. OneuniquefeatureforDivXinAVIcodecsisthatitsupportsN-passencoding,whereitsuccessivelyrefinesthecompressioninmultiplepasses.DivXperformsN-passencodinginaroundaboutfashionbybuildingadummyAVIfilewiththecomplexitydatastoredinitforthefirst pass,andthenitusesthatdummyfileforthesecondpass.Sometoolsautomatethisprocess, othersrequireyoutoperformitmanually.It’srarewhenmorethanthreepassescontinueto improvethecompression;eventhedifferencebetweentwoandthreepassesisquiteslight. DivXhasaspecificpsychovisualmodeinwhichaninternalmodelselectsthepartsoftheimage thatareofgreaterinteresttothehumanvisualsystem,andthenthecodecattemptstodistribute bitstothoseparts.UsingtheLightsettingisquitesafe;however,theExtremesettingcanproduceoddresults.Still,atverylowbitrates,thismodecanprovideameaningfulimprovement withsomecontent. DivXletsyoumanuallysetthethresholdfortriggeringanewnaturalkeyframe.Thedefaultof 50isagreatstartingpointformostcontent.DivXalsoallowsfivelevelsoftrade-offbetween qualityandspeedofencoding.Timepermitting,alwaysusetheSlowestmode. CompressionPrimer
53
AVIaudiocodecs AudiocodecsinAVIdon’treceivethesameattentionasthevideocodecs,butaudiocodecsare justasimportant,andthereisavastvarietyofthem.Thefollowinglistcontainsafewofthe mostimportant. Nonecodec ThemostbasicaudiocodecisNone,anuncompressedmodeliketheQuickTimeNonecodec.It ismainlyusefulforintermediates,notdelivery. IMAADPCMcodec TheIMAcodecisthesameastheoneinQuickTime,offeringa4:1compressionovertheNone codecwithdecentquality.It’sthemostuniversalaudiocodecforAVIandhasaverylight decoder. MSADPCMcodec TheMSADPCMisaslightvariantofIMA.Itdoesn’tofferanyadvantagesoverIMA,andit’s slightlylesscompatible,soyoudon’tneedtouseitforauthoring. MP3codec TheMP3codecispopularwithAVI.However,VBRMP3audioisn’tnearlyaswidelysupported asCBRMP3.WindowsshipswithaverylimitedMP3encoderforAVIthatmaximizesat56 Kbps.However,anumberofgoodthird-partyencodersareavailable.
Adobe Systems Incorporated • 345 Park Avenue, San Jose, CA 95110-2704 USA • www.adobe.com Adobe, the Adobe logo, Acrobat, Adobe Audition, Adobe Premiere, After Effects, Illustrator, Imageready, Photoshop are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States and/or other countries. Mac and Macintosh are trademarks of Apple Computer, Inc., registered in the United States and other countries. Intel and Pentium are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries. Microsoft and Windows are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. All other trademarks are the property of their respective owners. © 2004 Adobe Systems Incorporated. All rights reserved. Printed in the USA.