Changes between Version 35 and Version 36 of CompilationGuide/MacOSX


Ignore:
Timestamp:
Aug 4, 2017, 2:20:12 PM (5 months ago)
Author:
slhck
Comment:

redirect to macOS guide

Legend:

Unmodified
Added
Removed
Modified
  • CompilationGuide/MacOSX

    v35 v36  
    1 [[PageOutline(1-100, Contents)]] 
    2  
    3 There are a few ways to get FFmpeg on OS X. 
    4  
    5 One is to build it yourself.  Compiling on Mac OS X is as easy as any other *nix machine, there are just a few caveats. The general procedure is get the source, then {{{./configure <flags>; make && sudo make install}}}, though specific configure flags are possible. 
    6  
    7 Another is to use some "build helper" tool, to install it for you.  For example, homebrew or macports, see the homebrew section in this document. 
    8  
    9 Alternatively, if you are unable to compile, or do not want to install homebrew, you can simply [https://ffmpeg.org/download.html download a static build for OS X], but it may not contain the features you want.  Typically this involves unzipping an FFmpeg distribution file [like .zip file], then running it from within the newly extracted files/directories. 
    10  
    11 == ffmpeg through Homebrew == 
    12  
    13 [http://brew.sh/ Homebrew] is a command-line package manager, which is quite similar to `apt-get` on popular Linux distributions. In order to use it, you need to install `brew` first, if you haven't already: 
    14  
    15 {{{ 
    16 /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 
    17 }}} 
    18  
    19 Follow the on-screen instructions. This will take a few minutes while it's installing the necessary developer tools for OS X. After it success, next run: 
    20  
    21 {{{ 
    22 brew install ffmpeg 
    23 }}}  
    24  
    25 to get the latest released version with minimal configuration (and library dependency) options. These versions are packaged as Homebrew formulas and will take care of all the dependencies and the installation itself. You can run {{{brew info ffmpeg}}} to see additional install options, e.g. in order to enable {{{libfdk_aac}}} or {{{libvpx}}}, which is highly recommended. Example with some additional recommended options: 
    26  
    27 {{{ 
    28 brew install ffmpeg --with-fdk-aac --with-tools --with-freetype --with-libass --with-libvorbis --with-libvpx --with-x265 
    29 }}} 
    30  
    31 If you don't know how to configure and compile a binary, you will find using Homebrew quite easy. To later upgrade your `ffmpeg` version to the latest released, simply run: 
    32  
    33 {{{ 
    34 brew update && brew upgrade ffmpeg 
    35 }}} 
    36  
    37 If you want to install the latest Git version of FFmpeg using Homebrew, follow the above directions, but add a --HEAD to the install command, ex: 
    38  
    39 {{{ 
    40 brew install ffmpeg <install_options_if_desired> --HEAD 
    41 }}} 
    42  
    43 If instead you want to manually compile the latest Git version of FFmpeg, just continue with this guide. 
    44  
    45 == Compiling FFmpeg yourself == 
    46  
    47 === Xcode === 
    48  
    49 Starting with Lion 10.7, Xcode is available for free from the Mac App Store and is required to compile anything on your Mac. Make sure you install the Command Line Tools from Preferences > Downloads > Components. Older versions are still available with an AppleID and free Developer account at [http://developer.apple.com developer.apple.com]. 
    50  
    51 === Homebrew === 
    52  
    53 To get ffmpeg for OS X, you first have to install [http://brew.sh/ Homebrew]. If you don't want to use Homebrew, see the section below. 
    54  
    55 {{{ 
    56 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 
    57 }}} 
    58  
    59 Then: 
    60  
    61 {{{ 
    62 brew install automake fdk-aac git lame libass libtool libvorbis libvpx \ 
    63 opus sdl shtool texi2html theora wget x264 x265 xvid yasm 
    64 }}} 
    65  
    66 Mac OS X Lion comes with Freetype already installed (older versions may need 'X11' selected during installation), but in an atypical location: `/usr/X11`. Running `freetype-config` in Terminal can give the locations of the individual folders, like headers, and libraries, so be prepared to add lines like {{{CFLAGS=`freetype-config --cflags` LDFLAGS=`freetype-config --libs` PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:/usr/X11/lib/pkgconfig }}} before {{{./configure}}} or add them to your `$HOME/.profile` file. 
    67  
    68 === Manual install of the dependencies without Homebrew === 
    69  
    70 ==== Pkg-config & GLib  ==== 
    71  
    72 Pkg-config is necessary for detecting some of the libraries you can compile into FFmpeg, and it requires GLib which is not included in Mac OS X (but almost every other *nix distribution). You may either download pkg-config 0.23, or download the large tarball from [http://ftp.gnome.org/pub/GNOME/sources/glib/ Gnome.org] and compile it. Pkg-config is available from [http://pkgconfig.freedesktop.org/releases/ Freedesktop.org].  
    73  
    74 To compile GLib, you must also download gettext from [ftp://ftp.gnu.org/gnu/gettext/ GNU.org] and edit the file stpncpy.c to add "#undef stpncpy" just before "#ifndef weak_alias". Lion has its own (incompatible) version of the stpncpy function, which overlaps in gettext. Compile gettext as usual. Compile GLib with {{{LIBFFI_CFLAGS=-I/usr/include/ffi LIBFFI_LIBS=-lffi ./configure;make && sudo make install}}}  
    75  
    76 To compile pkg-config, run {{{GLIB_CFLAGS="-I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include" GLIB_LIBS="-lglib-2.0 -lgio-2.0" ./configure --with-pc-path="/usr/X11/lib/pkgconfig:/usr/X11/share/pkgconfig:/usr/lib/pkgconfig:/usr/local/lib/pkgconfig"}}}  
    77  
    78  
    79 ==== Yasm ==== 
    80  
    81 Yasm is available from [http://yasm.tortall.net/Download.html tortall.net] and is necessary for compiling C code that contains machine-independent Assembler code. To install, run {{{./configure --enable-python; make && sudo make install}}}  
    82  
    83 ==== Additional libraries ==== 
    84  
    85 These are just some examples. Run {{{./configure --help}}} for all available options. 
    86  
    87 * [http://www.videolan.org/developers/x264.html x264] encodes H.264 video. Use `--enable-gpl --enable-libx264`. 
    88 * [http://sourceforge.net/projects/opencore-amr/files/fdk-aac/ fdk-aac] encodes AAC audio. Use `--enable-libfdk-aac`. 
    89 * [https://code.google.com/p/webm/downloads/list libvpx] is a VP8 and VP9 encoder. Use `--enable-libvpx`. 
    90 * [http://downloads.xiph.org/releases/vorbis/ libvorbis] encodes Vorbis audio . Requires [http://downloads.xiph.org/releases/ogg/ libogg]. Use `--enable-libvorbis`. 
    91 * [http://www.opus-codec.org/downloads/ libopus] encodes Opus audio. 
    92 * [http://sourceforge.net/projects/lame/files/lame/ LAME] encodes MP3 audio. Use `--enable-libmp3lame`. 
    93 * [https://github.com/libass/libass libass] is a subtitle renderer. Use `--enable-libass`. 
    94  
    95 === Compiling === 
    96 Once you have compiled all of the codecs/libraries you want, you can now download the FFmpeg source either with Git or the from release tarball links on the website. Study the output of {{{./configure --help}}} and make sure you've enabled all the features you want, remembering that `--enable-nonfree` and `--enable-gpl` will be necessary for some of the dependencies above. A sample command is: 
    97  
    98 {{{ 
    99 git clone http://source.ffmpeg.org/git/ffmpeg.git ffmpeg 
    100 cd ffmpeg 
    101 ./configure  --prefix=/usr/local --enable-gpl --enable-nonfree --enable-libass \ 
    102 --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame \ 
    103 --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libopus --enable-libxvid 
    104 make && sudo make install 
    105 }}} 
     1See [[CompilationGuide/macOS]]