标签:style blog http color io os ar for sp
最近需要用到ffmpeg开发视频相关。在网上找了些编译资源,自己摸索着,总算编译ok了。
因此,记录下苦逼的编译过程,已祭奠我为之逝去的青春。
1、准备工作
首先,到ffmpeg官网下载最新到代码。
然后,https://github.com/lajos/iFrameExtractor 下载这个示例程序。并将里面的 gas-preprocessor.pl
拷贝到 /usr/local/bin
文件夹。
2、编译
首先,附上编译原文:
git clone git://github.com/PinkyJie/iFrameExtractor.git
git clone git://source.ffmpeg.org/ffmpeg.git
Put the ffmpeg source code into the folder ffmpeg
Copy the perl script gas-preprocessor.pl
into /usr/local/bin
folder
Change directory to your ffmpeg
folder, select
your target platform and follow the scripts below
armv7
(for iPhone 3GS and devices after 3GS)./configure \
--cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
--as=‘/usr/local/bin/gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc‘ \
--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk \
--target-os=darwin \
--arch=arm \
--cpu=cortex-a8 \
--extra-cflags=‘-arch armv7‘ \
--extra-ldflags=‘-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk‘ \
--prefix=compiled/armv7 \
--enable-cross-compile \
--enable-nonfree \
--enable-gpl \
--disable-armv5te \
--disable-swscale-alpha \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-asm \
--disable-debug
make clean
make && make install
armv6
(for devices before 3GS)./configure \
--cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
--as=‘/usr/local/bin/gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc‘ \
--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk \
--target-os=darwin \
--arch=arm \
--cpu=arm1176jzf-s \
--extra-cflags=‘-arch armv6‘ \
--extra-ldflags=‘-arch armv6 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk‘ \
--prefix=compiled/armv6 \
--enable-cross-compile \
--enable-nonfree \
--enable-gpl \
--disable-armv5te \
--disable-swscale-alpha \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-asm \
--disable-debug
make clean
make && make install
i386
(for simulator)./configure \
--cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc \
--as=‘/usr/local/bin/gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc‘ \
--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk \
--target-os=darwin \
--arch=i386 \
--cpu=i386 \
--extra-cflags=‘-arch i386‘ \
--extra-ldflags=‘-arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk‘ \
--prefix=compiled/i386 \
--enable-cross-compile \
--enable-nonfree \
--enable-gpl \
--disable-armv5te \
--disable-swscale-alpha \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-asm \
--disable-debug
make clean
make && make install
universal
(using one *.a files for all platforms)mkdir -p ./compiled/fat/lib
lipo -output ./compiled/fat/lib/libavcodec.a -create \
-arch armv6 ./compiled/armv6/lib/libavcodec.a \
-arch armv7 ./compiled/armv7/lib/libavcodec.a \
-arch i386 ./compiled/i386/lib/libavcodec.a
lipo -output ./compiled/fat/lib/libavdevice.a -create \
-arch armv6 ./compiled/armv6/lib/libavdevice.a \
-arch armv7 ./compiled/armv7/lib/libavdevice.a \
-arch i386 ./compiled/i386/lib/libavdevice.a
lipo -output ./compiled/fat/lib/libavformat.a -create \
-arch armv6 ./compiled/armv6/lib/libavformat.a \
-arch armv7 ./compiled/armv7/lib/libavformat.a \
-arch i386 ./compiled/i386/lib/libavformat.a
lipo -output ./compiled/fat/lib/libavutil.a -create \
-arch armv6 ./compiled/armv6/lib/libavutil.a \
-arch armv7 ./compiled/armv7/lib/libavutil.a \
-arch i386 ./compiled/i386/lib/libavutil.a
lipo -output ./compiled/fat/lib/libswresample.a -create \
-arch armv6 ./compiled/armv6/lib/libswresample.a \
-arch armv7 ./compiled/armv7/lib/libswresample.a \
-arch i386 ./compiled/i386/lib/libswresample.a
lipo -output ./compiled/fat/lib/libpostproc.a -create \
-arch armv6 ./compiled/armv6/lib/libpostproc.a \
-arch armv7 ./compiled/armv7/lib/libpostproc.a \
-arch i386 ./compiled/i386/lib/libpostproc.a
lipo -output ./compiled/fat/lib/libswscale.a -create \
-arch armv6 ./compiled/armv6/lib/libswscale.a \
-arch armv7 ./compiled/armv7/lib/libswscale.a \
-arch i386 ./compiled/i386/lib/libswscale.a
lipo -output ./compiled/fat/lib/libavfilter.a -create \
-arch armv6 ./compiled/armv6/lib/libavfilter.a \
-arch armv7 ./compiled/armv7/lib/libavfilter.a \
-arch i386 ./compiled/i386/lib/libavfilter.a
ffmpeg/compiled
folder.我想编译armv7。
然后,发现在xcode6下,上述/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc
路径下根本没有gcc,于是找啊找,??在
/Applications/Xcode.app/Contents/Developer/usr/bin/gcc
找到了gcc,行啊,试试吧!
编译OK,顺利生成了。a文件。
3、将库拷贝到示例程序中,编译,出错。提示xxxxx undefined symbols for armv7
好吧,又苦苦百度了一遍,度娘没搭理我啊。
突然发现,生成的库文件还有个pkgconfig目录,里面找到那个提示文件libavcodec相关的libavcodec.pc文件,打开一看,没怎么看懂,里面有一行说:
Libs: -L${libdir} -lavcodec -framework CoreVideo -framework Foundation -framework AVFoundation -framework CoreMedia -liconv -lm -lbz2 -lz -pthread
于是,我就在xcode的BuildSettings里面的other link flags里面加入了 -liconv,1??竟然好使!!!
4、我靠,就先这么着吧。
还望过路的大神们,指教指教。
macOS10.9+xcode6编译ffmpeg2.4.2 for ios
标签:style blog http color io os ar for sp
原文地址:http://blog.csdn.net/ouyangtianhan/article/details/40395253