ffmpeg through Homebrew

There are a few ways to get FFmpeg on OS X.

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.

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.

Alternatively, if you are unable to compile, or do not want to install homebrew, you can simply 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.

ffmpeg through Homebrew

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:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

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:

brew install ffmpeg

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:

brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-libvorbis --with-libvpx --with-opus --with-x265

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:

brew update && brew upgrade ffmpeg

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:

brew install ffmpeg <install_options_if_desired> --HEAD

If instead you want to manually compile the latest Git version of FFmpeg, just continue with this guide.

Compiling FFmpeg yourself

Xcode

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 developer.apple.com.

Homebrew

To get ffmpeg for OS X, you first have to install Homebrew. If you don't want to use Homebrew, see the section below.

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then:

brew install automake fdk-aac git lame libass libtool libvorbis libvpx \
opus sdl shtool texi2html theora wget x264 xvid yasm

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-configin 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.

Manual install of the dependencies without Homebrew

Pkg-config & GLib

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 Gnome.org and compile it. Pkg-config is available from Freedesktop.org.

To compile GLib, you must also download gettext from 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

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"

Yasm

Yasm is available from 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

Additional libraries

These are just some examples. Run ./configure --help for all available options.

  • x264 encodes H.264 video. Use --enable-gpl --enable-libx264.
  • fdk-aac encodes AAC audio. Use --enable-libfdk-aac.
  • libvpx is a VP8 and VP9 encoder. Use --enable-libvpx.
  • libvorbis encodes Vorbis audio . Requires libogg. Use --enable-libvorbis.
  • libopus encodes Opus audio.
  • LAME encodes MP3 audio. Use --enable-libmp3lame.
  • libass is a subtitle renderer. Use --enable-libass.

Compiling

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:

git clone http://source.ffmpeg.org/git/ffmpeg.git ffmpeg
cd ffmpeg
./configure  --prefix=/usr/local --enable-gpl --enable-nonfree --enable-libass \
--enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus \
--enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid
make && sudo make install
https://trac.ffmpeg.org/wiki/CompilationGuide/MacOSX
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值