1、下载ffmpeg,我使用xcode自带的git下载。
或者直接下载压缩包:
2、下载gas-preprocessor脚本 https://raw.github.com/mansr/gas-preprocessor/master/gas-preprocessor.pl 并且放到 /usr/bin 中。
3、安装pkgconfig(遇到 pkg-config not found 和 glib 报错时需要安装再重新编译FFMPEG)
(一)下载安装: http://pkgconfig.freedesktop.org/releases/
cd pkg-config-0.28
./configure --with-ssl=openssl
make
sudo make install
注意:
若出现 no targets specified and no makefile found 则可能是 configure 失败;
若出现 configure: error: pkg-config and "glib-2.0 >= 2.16" not found, please set GLIB_CFLAGS and GLIB_LIBS to the correct values or pass --with-internal-glib to configure
解决办法:
(二)安装glib:http://ftp.acc.umu.se/pub/gnome/sources/glib/
# wget http://ftp.gnome.org/pub/gnome/sources/glib/2.22/glib-2.22.5.tar.gz
# tar xvfz glib-2.22.5.tar.gz
# cd glib-2.22.5
# ./configure --prefix=/usr/local/glib-2.2
# make && make install
设置环境变量:
export GLIB_CFLAGS="-I/usr/local/glib-2.2/include/glib-2.0"
export GLIB_LIBS="-L/usr/local/glib-2.2/lib/glib-2.0"
export GMODULE_CFLAGS="-I/usr/local/glib-2.2/include"
export GMODULE_LIBS="-L/usr/local/glib-2.2/lib"
export GTHREAD_CFLAGS="-I/usr/local/glib-2.2/include"
export GTHREAD_LIBS="-L/usr/local/glib-2.2/lib"
特别强调,GMODULE和GTHREAD的相关变量必须设置,否则会遇到(gmodule-2.0 >= 2.16.0) were not met或(gthread-2.0 >= 2.16.0) were not met之类错误。(参考:http://blog.csdn.net/ldl22847/article/details/8576052)
懒得写了,按这个来做,OK
http://blog.csdn.net/cococoolwhj/article/details/8714424
测试DEMO时,添加 libbz2.dylib、libz.dylib、libiconv.dylib,修改 Header Search Paths 和 Library Search Paths 这两者的编译选项为正确的路径。
最后上图,模拟器上跑的,i386:
iphone4s 上跑的,armv7: