Hunter Ford Hunter Ford

Compiling FFMpeg on Mac OS X

You must have Xcode installed with Unix Tools. Xcode 3 is available for free via Apple Developer Center. However, Xcode 4 is available through the App Store (free for Lion users).

# Create a temporary directory for sources.
SOURCES=$(mktemp -d /tmp/XXXXXXXXXX)

# Download the necessary sources.
curl -#LO
curl -#LO
curl -#LO
curl -#LO
curl -#LO
curl -#LO
# curl -#LO
curl -#LO
curl -#LO
curl -#LO
curl -#LO
# curl -#LG -d "p=ffmpeg.git;a=snapshot;h=HEAD;sf=tgz" -o ffmpeg.tar.gz
curl -#LO

# Unpack files
for file in `ls ${SOURCES}/*.tar.*`; do
    tar -xzf $file
    rm $file

cd faac-*/
CFLAGS="-D__unix__" ./configure && make -j 4 && sudo make install; cd ..

cd lame-*/
./configure && make -j 4 && sudo make install; cd ..

cd libogg-*/
./configure && make -j 4 && sudo make install; cd ..

cd pkg-config-*/
./configure && make -j 4 && sudo make install; cd ..

cd libvorbis-*/
./configure --disable-oggtest --build=x86_64 && make -j 4 && sudo make install; cd ..

cd libtheora-*/
./configure --disable-oggtest --disable-vorbistest --disable-examples --disable-asm
make -j 4 && sudo make install; cd ..

# cd vo-amrwbenc-*/
# ./configure && make -j 4 && sudo make install; cd ..

cd yasm-*/
./configure && make -j 4 && sudo make install; cd ..

cd libvpx-*/
./configure --enable-vp8 --enable-pic && make -j 4 && sudo make install; cd ..

cd x264-*
CFLAGS="-I. -fno-common -read_only_relocs suppress" ./configure --enable-pic --enable-shared && make -j 4 && sudo make install; cd ..

cd xvidcore/build/generic
./configure --disable-assembly && make -j 4 && sudo make install; cd ../../..

# For Lion, we have to change which compiler to use (--cc=clang).
# If you're building on Snow Leopard, you can omit this flag so it defaults to gcc.
cd ffmpeg-*/
CFLAGS="-DHAVE_LRINTF" ./configure --enable-nonfree --enable-gpl --enable-version3 --enable-postproc --enable-swscale --enable-avfilter --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libfaac --enable-libxvid --enable-libx264 --enable-libvpx --enable-hardcoded-tables --enable-shared --enable-pthreads --disable-indevs --cc=clang && make -j 4 && sudo make install

# --enable-libvo-amrwbenc

# FFMpeg creates MP4s that have the metadata at the end of the file.
# This tool moves it to the beginning.
cd tools
gcc -D_LARGEFILE_SOURCE qt-faststart.c -o qt-faststart
sudo mv qt-faststart /usr/local/bin



  • Redic

  • Alvaro

    Hello Hunter, The fisrt is to give you a lot of thanks for your excellent work. I have used it in my tutorial called: Installation OpenMeetings 3.0.x on Mac Yosemite OS X.pdf As it is in this web doesn't work with OpenMeetings, but i made some modifications and so works rightly. To give you a lot of thanks once more! Best Regards Alvaro
  • Nitesh Dulal

    Hi Thanks , I could successfully compile with the above instruction. Any idea how i can create a binary out of this?? Any help would be very much appreciated Thanks in advance

    Thank You so worked.
  • Brandon

    Hunter, I've updated your download links to their latest versions:
  • Mark Fleming

    I also need to update to version 1.20 curl -#LO and then it worked well in 10.8.2 one line I would add is: ls /usr/local/lib at the end of the script for check if all was install correctly. and display $Source folder if user needs to trouble shoot it. Thank you Mark
  • Brent

    x264 said it needed at least yasm-1.2.0. So I used that one instead and it worked! Thank you for putting this together.
  • Andreas Westh

    Good job! Works as intended on 10.7.4
  • Seereen

    I think I installed this perfectly in my mac with OS 10.7.4 .... now I am trying to build this program in this link but I got many errors !!!! Do you know where is the problems ! ... in the OS or in this code ... or the version of ffmpeg !!! Thanks in advance
  • Esteban

    Works perfect on 10.7.4
  • Darrel Hunt

    I was wondering if anyone has an ffmpeg binary w/faac compiled already they could send me.
  • Yakumo Fuji

    Hi, I had a lite trouble with this script such as that yasm did not want to download so I found an alternate site to download version 1.2 from. Also the script did not unpack .tar.bz2 packages for me so I changed that so it is working. Here is an updated link to the install script.
  • mpsrig

    Hey, great post, thanks for the tip about the --cc=clang on Lion. I was wondering why this is necessary vs. gcc? Thanks?
  • Dimitar Dimitrov

    Unfortunately I'm getting "ERROR: libxvid not found". libxvidcore.a is in /usr/local/lib, xvid.h is in /usr/local/include, but I'm still getting this. Any suggestions?
  • Julio Aguirre

    After several hours of internet search about the error in liborvis not found error i found the fix. The problem is that the configure param of liborbis must be ./configure --build=x86_6 That fix the problem for me. Usign lion 10.7.2 In this site i put the updated script code to include the latest version of all codecs as octber 31 2011.
  • Niklas Br

    Thanks for sharing Hunter, but I have the same error as Jason and after digging in the libvorbis make code for two hours I am no closer to solving this. See log at
  • Jason

    the libvorbis step does not work for me. checking for OGG... no checking for Ogg... yes checking for oggpack_writealign... no configure: error: Ogg >= 1.0 required ! I am doing: ./configure --disable-oggtest && make -j 4 && sudo make install; cd .. anyone have any idea how to fix?
  • Glenn

    Hunter responded to my above post via email so I thought I would share with anyone else that might be having issues. Download the above script and just replace the "cd ffmpeg..." line with: cd ffmpeg-*/; CFLAGS="-DHAVE_LRINTF" ./configure --cc=clang --enable-nonfree --enable-gpl --enable-version3 --enable-postproc --enable-swscale --enable-avfilter --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libfaac --enable-libxvid --enable-libx264 --enable-libvpx --enable-libvo-amrwbenc --enable-shared --enable-pthreads --disable-indevs The only change was adding --cc=clang just after configure. This successfully compiled on Lion with Xcode 4.
  • Glenn

    The Lion update seems to have broken the script. Any chance of getting an update for OS X Lion? It would be much appreciated.
  • dezza

    Thanks so much for posting this. It worked perfectly for me on 10.6.7.
  • Eric Pardee

    Great post Hunter, much appreciated. This worked perfectly on my OS X 10.6.7. Saved me a tremendous amount of time by not having to deal with all the OS X compatibility issues for each library or learn the configure flags. Please contact me if you're interested in freelance work in television post-production.
  • Hunter Ford

    I'm glad it worked for you! Thanks for pointing out my typo; it's been fixed!
  • JTDS

    Great work, this is exactly what I was looking for! But watch the Freudian typo "CLFAGS" in line 36 ;o) At first the script crashed for me, because curl wouldn't load the x264 bundle via FTP, so I downloaded it from VideoLAN's Mac-ish site: In the end, all compiled and installed beautifully using XCode 3.2.6 on a MacBook Core 2 Duo running 10.6.7 Snow Leopard. Works great for the .mpeg to .flv conversions I needed. Thanks!