Changes between Version 4 and Version 5 of CompilationGuide/macOS
- Timestamp:
- Oct 30, 2017, 10:34:34 AM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CompilationGuide/macOS
v4 v5 1 1 [[PageOutline(1-100, Contents)]] 2 2 3 There are a few ways to get FFmpeg on macOS .3 There are a few ways to get FFmpeg on macOS: 4 4 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.5 1. 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. 6 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.7 2. 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. 8 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 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.9 3. 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. 10 10 11 11 == ffmpeg through Homebrew == 12 12 13 [http://brew.sh/ Homebrew] is a command-line package manager, which is quitesimilar 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: 14 14 15 15 {{{ … … 27 27 === Specifying additional options === 28 28 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 recommendedoptions:29 You 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: 30 30 31 31 {{{ 32 brew install ffmpeg --with-fdk-aac --with-tools --with-freetype --with-libass --with-libvorbis --with-libvpx --with-x265 32 brew 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 33 42 }}} 34 35 If you don't know how to configure and compile a binary, you will find using Homebrew quite easy.36 43 37 44 === Updating ffmpeg === … … 43 50 }}} 44 51 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 55 If 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: 46 56 47 57 {{{ 48 brew install ffmpeg <install_options_if_desired>--HEAD58 brew install ffmpeg --with-tools --with-fdk-aac --with-libvpx --with-x265 --HEAD 49 59 }}} 50 60 51 If instead you want to manually compile the latest Git version of FFmpeg, just continue with this guide. 61 ----- 52 62 53 63 == Compiling FFmpeg yourself == … … 55 65 === Xcode === 56 66 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 67 Xcode 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 69 After installing Xcode, install the ''Command Line Tools'' from ''Preferences > Downloads > Components''. You can also install the tools via your shell: 58 70 {{{ 59 71 xcode-select --install … … 61 73 62 74 63 === Homebrew ===75 === Installing dependencies with Homebrew === 64 76 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.77 To get some dependencies for ffmpeg, you can install [http://brew.sh/ Homebrew]. 66 78 67 79 {{{ … … 76 88 }}} 77 89 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 }}} 81 94 82 95 === Manual install of the dependencies without Homebrew === … … 84 97 ==== Pkg-config & GLib ==== 85 98 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].99 Pkg-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]. 87 100 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}}}101 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`. Mac OS X Lion has its own (incompatible) version of the `stpncpy` function, which overlaps in `gettext`. Compile `gettext` as usual. Compile GLib with 89 102 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 {{{ 104 LIBFFI_CFLAGS=-I/usr/include/ffi LIBFFI_LIBS=-lffi ./configure;make && sudo make install 105 }}} 106 107 To compile pkg-config, run 108 109 {{{ 110 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" 111 }}} 91 112 92 113 … … 94 115 95 116 Nasm is an assembler required for x264. The latest version is available at [[http://nasm.us|nasm.us]]. 96 97 117 98 118 ==== Additional libraries ==== … … 108 128 * [https://github.com/libass/libass libass] is a subtitle renderer. Use `--enable-libass`. 109 129 130 === Freetype === 131 132 macOS already comes with freetype installed (older versions may need X11 selected during installation), but in an atypical location: `/opt/X11/`. 133 134 Running `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 {{{ 137 CFLAGS=`freetype-config --cflags` 138 LDFLAGS=`freetype-config --libs` PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:/opt/X11/lib/pkgconfig 139 }}} 140 141 in your `./configure` command. 142 110 143 === Compiling === 144 111 145 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: 112 146 … … 117 151 --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame \ 118 152 --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libopus --enable-libxvid 119 make && sudo make install153 make 120 154 }}} 155 156 After 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`.
