You are on page 1of 2

11/28/2015

ffmpegtutorial

AnffmpegandSDLTutorial
or

HowtoWriteaVideoPlayerin
LessThan1000Lines
Page1234567End
PrevHomeNext

UPDATE:
Thistutorialisupto
dateasofFebruary
2015.
ffmpegisawonderfullibraryforcreatingvideo
applicationsorevengeneralpurposeutilities.ffmpeg
takescareofallthehardworkofvideoprocessingby
doingallthedecoding,encoding,muxingand
demuxingforyou.Thiscanmakemediaapplications
muchsimplertowrite.It'ssimple,writteninC,fast,
andcandecodealmostanycodecyou'llfindinuse
today,aswellasencodeseveralotherformats.
Theonlyproblemisthatdocumentationwas
basicallynonexistent.Thereisasingletutorialthat
showsthebasicsofffmpegandautogenerated
doxygendocuments.That'sit.So,whenIdecidedto
learnaboutffmpeg,andintheprocessabouthow
digitalvideoandaudioapplicationswork,Idecided
todocumenttheprocessandpresentitasatutorial.
Thereisasampleprogramthatcomeswithffmpeg
calledffplay.ItisasimpleCprogramthat
implementsacompletevideoplayerusingffmpeg.
Thistutorialwillbeginwithanupdatedversionofthe
originaltutorial,writtenbyMartinBhme(Ihave
stolenliberallyborrowedfromthatwork),andwork
fromtheretodevelopingaworkingvideoplayer,
basedonFabriceBellard'sffplay.c.Ineachtutorial,
I'llintroduceanewidea(ortwo)andexplainhowwe
implementit.EachtutorialwillhaveaCfilesoyou
candownloadit,compileit,andfollowalongat
home.Thesourcefileswillshowyouhowthereal
programworks,howwemoveallthepiecesaround,
aswellasshowingyouthetechnicaldetailsthatare
http://dranger.com/ffmpeg/

1/2

11/28/2015

ffmpegtutorial

unimportanttothetutorial.Bythetimeweare
finished,wewillhaveaworkingvideoplayerwritten
inlessthan1000linesofcode!
Inmakingtheplayer,wewillbeusingSDLtooutput
theaudioandvideoofthemediafile.SDLisan
excellentcrossplatformmultimedialibrarythat's
usedinMPEGplaybacksoftware,emulators,and
manyvideogames.Youwillneedtodownloadand
installtheSDLdevelopmentlibrariesforyoursystem
inordertocompiletheprogramsinthistutorial.
Thistutorialismeantforpeoplewithadecent
programmingbackground.Attheveryleastyou
shouldknowCandhavesomeideaaboutconcepts
likequeues,mutexes,andsoon.Youshouldknow
somebasicsaboutmultimediathingslike
waveformsandsuch,butyoudon'tneedtoknowa
lot,asIexplainalotofthoseconceptsinthis
tutorial.
TherearealsooldschoolASCIIfilesofthetutorials.
Youcanalsogetatarballofthetextfilesandsource
codeorjustthesource.
Pleasefeelfreetoemailmewithbugs,questions,
comments,ideas,features,whatever,at dranger

atgmaildotcom.
>>Proceedwiththetutorial!
FunctionReference
DataReference

email: drangeratgmaildotcom
Backtodranger.com

ThisworkislicensedundertheCreativeCommonsAttributionShare
Alike2.5License.Toviewacopyofthislicense,visit
http://creativecommons.org/licenses/bysa/2.5/orsendaletterto
CreativeCommons,543HowardStreet,5thFloor,SanFrancisco,
California,94105,USA.
CodeexamplesarebasedoffofFFplay,Copyright(c)2003Fabrice
Bellard,andatutorialbyMartinBohme.

http://dranger.com/ffmpeg/

2/2

You might also like