赞
踩
There are a few ways to get FFmpeg on OS X.
*
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. [like .zip file]
, then running it from within the newly extracted files/directories.使用git clone https://github.com/FFmpeg/FFmpeg
从github下载ffmpeg源码,切换到要使用的目标分支(这里使用release/3.3):git checkout -b r3.3 origin/release/3.3
,或者直接从github下载分支release/3.3
的压缩包,解压.
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.
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 x265 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-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.
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/ffmpeg --enable-gpl --enable-nonfree --enable-libass \
--enable-libfdk-aac --enable-libfreetype --enable-libmp3lame \
--enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libopus --enable-libxvid
make && sudo make install
--prefix
指定编译完成后安装路径,这里指定到/usr/local/ffmpeg
,安装完成会在/usr/local/ffmpeg
下生成:bin,include,lib,share四个目录
A package consists of several related files which are installed in several directories. The configure step usually allows the user to specify the so-called install prefix, and is usually specified through the configure option configure --prefix=PREFIX, where PREFIX usually is by default /usr/local. The prefix specifies the common directory where all the components are installed.
The following directories are usually involved in the installation:
PREFIX/bin
: contains the generated binaries (e.g. ffmpeg, ffplay, ffprobe etc. in the case of FFmpeg)PREFIX/include
: contains the library headers (e.g. libavutil/avstring.h, libavcodec/avcodec.h, libavformat/avformat.h etc. in case of FFmpeg) required to compile applications linked against the package librariesPREFIX/lib
: contains the generated libraries (e.g. libavutil, libavcodec, libavformat etc. in the case of FFmpeg)PREFIX/share
: contains various system-independent components; especially documentation files and examplesBy using a shared prefix like /usr/local/, different packages will be installed in the same directory, so in general it will be more difficult to revert the installation.
Using a prefix like /opt/PROJECT/, the project will be installed in a dedicated directory, and to remove from the system you can simply remove the /opt/PREFIX path. On the other hand, such installation will require to edit all the environment variables to point to the custom path.
Several variables defined in the environment affect your package install. In particular, depending on your installation prefix, you may need to update some of these variables in order to make sure that the installed components can be found by the system tools.
The list of environment variables can be shown through the command env.
A list of the affected variables follows:
Environment variables are usually defined in the profile file, for example .profile defined in the user directory for sh/bash users, and in /etc/profile. This file can be edited to permanently set the custom environment. Alternatively, the variables can be set in a script or in a particular shell session.
Remember to export the variables to the child process, e.g. using the export command. Read the fine documentation of your shell for more detailed information.
Windows下.DLL,Linux下.so,Mac OS X下的扩展名是.dylib。
.dylib是Mach-O格式,也就是Mac OS X下的二进制文件格式。Mac OS X提供了一系列
工具,用于创建和访问动态链接库。
cc -c a.c b.c
,就得到a.o和b.old -r -o c.o a.o b.o
libtool -dynamic -o c.dylib a.o b.o
.( 这里也可以用libtool -static -o c.a a.o b.o
就创建静态库)如果用gcc直接编译,我记得linux下一般是可以:
gcc -shared -o c.so a.c b.c
而在Mac OS X下需要:
gcc -dynamiclib -o c.dylib a.c b.c
nm是最常用的,这个用法跟linux下差不多:nm c.dylib
,可以看到导出符号表,等等。
另一个常用的工具是otool,这个是Mac OS X独有的。比如想看看c.dylib的依赖关系otool -L c.dylib
因为系统没有sdl环境或sdl版本不匹配,ffmpeg3.3需要sdl2
http://www.libsdl.org/download-2.0.php 下载Source Code SDL2-2.0.5.zip - GPG signed,解压缩,执行命令:
./configure
make
sudo make install
进行编译
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。