Changes between Version 4 and Version 5 of CompilationGuide/macOS


Ignore:
Timestamp:
Oct 30, 2017, 12:34:34 PM (3 weeks ago)
Author:
slhck
Comment:

grammar and introduction, update descriptions

Legend:

Unmodified
Added
Removed
Modified
  • CompilationGuide/macOS

    v4 v5  
    11[[PageOutline(1-100, Contents)]] 
    22 
    3 There are a few ways to get FFmpeg on macOS. 
     3There are a few ways to get FFmpeg on macOS: 
    44 
    5 One is to build it yourself.  Compiling on macOS 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. 
     51. Use a package manager like [https://brew.sh/ Homebrew] or [https://www.macports.org/ MacPorts] to install `ffmpeg`. These will automatically keep your FFmpeg installation up-to-date. See [#ffmpegthroughHomebrew the Homebrew section] below for more info. 
    66 
    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. 
     72. Download a [https://ffmpeg.org/download.html static build for macOS]. This is as easy as extracting and running the downloaded binary. One disadvantage with static builds is that updates have to be performed manually. Also, they may not contain all encoders or filters you want. 
    88 
    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 macOS], 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. 
     93. Build it yourself. Compiling on macOS is as easy as on any other *nix machine. Download the source, then run {{{./configure}}} with the needed flags, {{{make}}} and {{{make install}}}. However, the configuration options have to be set manually, and you will need to install third-party libraries yourself. See [#CompilingFFmpegyourself the compilation section] below for more info. 
    1010 
    1111== ffmpeg through Homebrew == 
    1212 
    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: 
     13[http://brew.sh/ Homebrew] is a command-line package manager, which is similar to `apt-get` on popular Linux distributions. In order to use it, you need to install `brew` first, if you haven't already: 
    1414 
    1515{{{ 
     
    2727=== Specifying additional options === 
    2828 
    29 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: 
     29You can run {{{brew info ffmpeg}}} to see additional install options, e.g. in order to enable {{{libfdk_aac}}} or {{{libvpx}}}, which are highly recommended. Here is an example with some additional options: 
    3030 
    3131{{{ 
    32 brew install ffmpeg --with-fdk-aac --with-tools --with-freetype --with-libass --with-libvorbis --with-libvpx --with-x265 
     32brew install ffmpeg \ 
     33    --with-tools \ 
     34    --with-fdk-aac \ 
     35    --with-freetype \ 
     36    --with-fontconfig \ 
     37    --with-libass \ 
     38    --with-libvorbis \ 
     39    --with-libvpx \ 
     40    --with-opus \ 
     41    --with-x265 
    3342}}} 
    34  
    35 If you don't know how to configure and compile a binary, you will find using Homebrew quite easy. 
    3643 
    3744=== Updating ffmpeg === 
     
    4350}}} 
    4451 
    45 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: 
     52 
     53=== Installing Git `HEAD` === 
     54 
     55If you want to install the latest Git version of `ffmpeg` instead of the release version, follow the above directions, but add a --HEAD to the install command. For example: 
    4656 
    4757{{{ 
    48 brew install ffmpeg <install_options_if_desired> --HEAD 
     58brew install ffmpeg --with-tools --with-fdk-aac --with-libvpx --with-x265 --HEAD 
    4959}}} 
    5060 
    51 If instead you want to manually compile the latest Git version of FFmpeg, just continue with this guide. 
     61----- 
    5262 
    5363== Compiling FFmpeg yourself == 
     
    5565=== Xcode === 
    5666 
    57 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]. Note that if you have recently upgraded you will also likely need to re-install the command line tools  
     67Xcode is required to compile software on your Mac. Install Xcode by [https://developer.apple.com/xcode/ downloading it from the website] or using the Mac App Store. 
     68 
     69After installing Xcode, install the ''Command Line Tools'' from ''Preferences > Downloads > Components''. You can also install the tools via your shell: 
    5870{{{ 
    5971xcode-select --install 
     
    6173 
    6274 
    63 === Homebrew === 
     75=== Installing dependencies with Homebrew === 
    6476 
    65 To get ffmpeg for macOS, you first have to install [http://brew.sh/ Homebrew]. If you don't want to use Homebrew, see the section below. 
     77To get some dependencies for ffmpeg, you can install [http://brew.sh/ Homebrew]. 
    6678 
    6779{{{ 
     
    7688}}} 
    7789 
    78 === Info on Freetype === 
    79  
    80 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. 
     90{{{ 
     91#!div style="border: 1px solid #c7e5c7; margin: 1em; background-color: #ddffdd;" 
     92'''Tip:''' If you don't want to use Homebrew to get the dependencies, see the section below. Using Homebrew will however save you time in setting up all the needed tools. 
     93}}} 
    8194 
    8295=== Manual install of the dependencies without Homebrew === 
     
    8497==== Pkg-config & GLib  ==== 
    8598 
    86 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].  
     99Pkg-config is necessary for detecting some of the libraries you can compile into FFmpeg, and it requires GLib, which is not included in macOS (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].  
    87100 
    88 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}}}  
     101To 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`. Mac OS X Lion has its own (incompatible) version of the `stpncpy` function, which overlaps in `gettext`. Compile `gettext` as usual. Compile GLib with 
    89102 
    90 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"}}}  
     103{{{ 
     104LIBFFI_CFLAGS=-I/usr/include/ffi LIBFFI_LIBS=-lffi ./configure;make && sudo make install 
     105}}}  
     106 
     107To compile pkg-config, run 
     108 
     109{{{ 
     110GLIB_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" 
     111}}} 
    91112 
    92113 
     
    94115 
    95116Nasm is an assembler required for x264. The latest version is available at [[http://nasm.us|nasm.us]]. 
    96  
    97117 
    98118==== Additional libraries ==== 
     
    108128* [https://github.com/libass/libass libass] is a subtitle renderer. Use `--enable-libass`. 
    109129 
     130=== Freetype === 
     131 
     132macOS already comes with freetype installed (older versions may need X11 selected during installation), but in an atypical location: `/opt/X11/`. 
     133 
     134Running `freetype-config` in Terminal can give the locations of the individual folders, like headers, and libraries, so be prepared to add lines like 
     135 
     136{{{ 
     137CFLAGS=`freetype-config --cflags` 
     138LDFLAGS=`freetype-config --libs` PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:/opt/X11/lib/pkgconfig 
     139}}} 
     140 
     141in your `./configure` command. 
     142 
    110143=== Compiling === 
     144 
    111145Once 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: 
    112146 
     
    117151--enable-libfdk-aac --enable-libfreetype --enable-libmp3lame \ 
    118152--enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libopus --enable-libxvid 
    119 make && sudo make install 
     153make 
    120154}}} 
     155 
     156After successful compilation, running `sudo make install` will install the ffmpeg binaries with superuser rights. You can also set a prefix during configuration, e.g. `--prefix="$HOME/bin`, where no root rights are needed  for `make install`.