如何为iphone编译ffmpeg
mkdir。/构建
#为armv7版本配置
。/配置\
-cc =/Developer/Platforms/iphone OS . platform/Developer/usr/bin/gcc \
-as = ' gas-preprocessor . pl/Developer/Platforms/iphone OS . platform/Developer/usr/bin/gcc ' \
-sysroot =/Developer/Platforms/iphone OS . platform/Developer/SDKs/iphone OS 4.3 . SDK \
-extra-LD flags =-L/Developer/Platforms/iphone OS . platform/Developer/SDKs/iphone OS 4.3 . SDK/usr/lib/system \
- target-os=darwin \
- arch=arm \
- cpu=cortex-a8 \
- extra-cflags='-arch armv7' \
- extra-ldflags='-arch armv7' \
- enable-pic \
-enable-交叉编译\
- disable-ffmpeg \
- disable-ffplay \
- disable-ffserver \
-禁用-doc
#为armv7构建
使干净
制造
#复制armv7库
mkdir。/build/armv7
cp -f ./libavcodec/libavcodec.a。/build/armv7/libavcodec.a
CP-f ./libavdevice/libavdevice . a。/build/armv7/libavdevice.a
CP-f ./libavfilter/libavfilter . a。/build/armv7/libavfilter.a
CP-f ./libavformat/libavformat . a。/build/armv7/libavformat.a
cp -f ./libavutil/libavutil.a。/build/armv7/libavutil.a
cp -f ./libswscale/libswscale.a。/build/armv7/libswscale.a
#为armv6版本配置
。/配置\
-cc =/Developer/Platforms/iphone OS . platform/Developer/usr/bin/gcc \
-as = ' gas-preprocessor . pl/Developer/Platforms/iphone OS . platform/Developer/usr/bin/gcc ' \
-sysroot =/Developer/Platforms/iphone OS . platform/Developer/SDKs/iphone OS 4.3 . SDK \
-extra-LD flags =-L/Developer/Platforms/iphone OS . platform/Developer/SDKs/iphone OS 4.3 . SDK/usr/lib/system \
- target-os=darwin \
- arch=arm \
- cpu=arm1176jzf-s \
- extra-cflags='-arch armv6' \
- extra-ldflags='-arch armv6' \
-enable-交叉编译\
- disable-ffmpeg \
- disable-ffplay \
- disable-ffserver \
-禁用-doc
#为armv6构建
使干净
制造
#复制armv6库
mkdir。/build/armv6
cp -f ./libavcodec/libavcodec.a。/build/armv6/libavcodec.a
CP-f ./libavdevice/libavdevice . a。/build/armv6/libavdevice.a
CP-f ./libavfilter/libavfilter . a。/build/armv6/libavfilter.a
CP-f ./libavformat/libavformat . a。/build/armv6/libavformat.a
cp -f ./libavutil/libavutil.a。/build/armv6/libavutil.a
cp -f ./libswscale/libswscale.a。/build/armv6/libswscale.a
#为i386版本配置
。/配置\
-cc =/Developer/Platforms/iphone simulator . platform/Developer/usr/bin/gcc \
-as = ' gas-preprocessor . pl/Developer/Platforms/iphone simulator . platform/Developer/usr/bin/gcc ' \
-sysroot =/Developer/Platforms/iphone simulator . platform/Developer/SDKs/iphone simulator 4.3 . SDK \
-extra-LD flags =-L/Developer/Platforms/iphone simulator . platform/Developer/SDKs/iphone simulator 4.3 . SDK/usr/lib/system \
- target-os=darwin \
- arch=i386 \
- cpu=i386 \
- extra-cflags='-arch i386' \
- extra-ldflags='-arch i386' \
-enable-交叉编译\
- disable-ffmpeg \
- disable-ffplay \
- disable-ffserver \
-禁用-doc
#为i386构建
使干净
制造
#复制出i386库
mkdir。/build/i386
cp -f ./libavcodec/libavcodec.a。/build/i386/libavcodec.a
CP-f ./libavdevice/libavdevice . a。/build/i386/libavdevice.a
CP-f ./libavfilter/libavfilter . a。/build/i386/libavfilter.a
CP-f ./libavformat/libavformat . a。/build/i386/libavformat.a
cp -f ./libavutil/libavutil.a。/build/i386/libavutil.a
cp -f ./libswscale/libswscale.a。/build/i386/libswscale.a
#制作脂肪(通用)libs
脂肪输出。/build/libavcodec.a -create \
-拱形臂v6。/build/armv6/libavcodec.a \
-arch armv7。/build/armv7/libavcodec.a \
-拱门i386。/build/i386/libavcodec.a
脂肪输出。/build/libavdevice.a -create \
-拱形臂v6。/build/armv6/libavdevice.a \
-arch armv7。/build/armv7/libavdevice.a \
-拱门i386。/build/i386/libavdevice.a
脂肪输出。/build/libavfilter.a -create \
-拱形臂v6。/build/armv6/libavfilter.a \
-arch armv7。/build/armv7/libavfilter.a \
-拱门i386。/build/i386/libavfilter.a
脂肪输出。/build/libavformat.a -create \
-拱形臂v6。/build/armv6/libavformat.a \
-arch armv7。/build/armv7/libavformat.a \
-拱门i386。/build/i386/libavformat.a
脂肪输出。/build/libavutil.a -create \
-拱形臂v6。/build/armv6/libavutil.a \
-arch armv7。/build/armv7/libavutil.a \
-拱门i386。/build/i386/libavutil.a
脂肪输出。/build/libswscale.a -create \
-拱形臂v6。/build/armv6/libswscale.a \
-arch armv7。/build/armv7/libswscale.a \
-拱门i386。/build/i386/libswscale.a
上面i386的编译器配置,也就是模拟器,不是必须的。下面是另一种配置方法:
。/配置\
- disable-bzlib \
- disable-mmx \
- disable-doc \
- disable-ffmpeg \
- disable-ffplay \
- disable-ffserver \
-cc =/Developer/Platforms/iphone simulator . platform/Developer/usr/bin/i686-apple-Darwin 10-gcc-4 . 2 . 1 \
-as = ' gas-preprocessor/gas-preprocessor . pl/Developer/Platforms/iphone simulator . platform/Developer/usr/bin/i686-apple-Darwin 10-gcc-4 . 2 . 1 ' \
-sysroot =/Developer/Platforms/iphone simulator . platform/Developer/SDKs/iphone simulator 4.0 . SDK \
-extra-c flags = '-f message-length = 0-pipe-Wno-trigraphs-fpascal-strings-O0-fasm-blocks-Wreturn-type-Wunused-variable-D _ _ IPHONE _ OS _ VERSION _ MIN _ REQ UIRED = 30000-isysroot/Developer/Platforms/IPHONE simulator . platform/Developer/SDKs/IPHONE simulator 4.0 . SDK-f visibility = hidden-mmacosx-VERSION-MIN = 10.5-1
另一篇文章
将值FFMPEG移动到iPhone或Mac OS/X
有关FFMPEG的详细描述,请参考互联网上的相关文档。这里只说FFMPEG迁移到iPhone或Mac OS/X的过程以及相关注意事项。
FFMPEG的功能相当强大,包括FFServer、FFPlay、FFMPEG、AVCODEC、AVDevice、AVFormat、AVutil、SWScale等。在完整的FFMPEG包中。其中ffserver、ffplay、ffmpeg是应用程序,对于我们这些从事软件开发的人来说基本没什么用。Avcodec是加密解码库,avformat是格式库,avutil是基本库(但我们很少用),swscale是图像处理库。所以我们想要的是转移这四个库的价值:avcodec,avformat,avutil和swscale。
将价值转移到Mac OS/X的过程:
一.配置
。/configure-prefix =/Developer/usr-cc =/Developer/usr/bin/gcc-4.0-enable-GPL-enable-shared-disable-IPv6-enable-SW scale-enable-zlib-enable-bzlib-disable-ffmpeg-disable-ff play-disable-ff server-disable-vhook
第二,编制
制造
第三,安装
进行安装
注意:上面的/Developer/usr是目标目录。如果您的Xcode是默认安装的,您可以在安装后在Xcode中编译和调试您的代码。
将值移动到Mac OS/X下的模拟iPhone平台的过程:
一.配置
。/configure-prefix =/Developer/usr-disable-debug-cc =/Developer/usr/bin/i686-apple-Darwin 9-gcc-4 . 0 . 1-enable-GPL-enable-static-disable-shared-disable-IPv6-enable-swscale-enable-zlib-enable-bzlib-disable-ffmpeg-disable-ff play-disable-ff server-disable-v hook-enable-pthreads
其中:还可以添加-启用-共享,这样可以让它编译生成动态库,以后编程会用到。-前缀设置的安装目录。如果在配置时没有添加- enable-shared,静态链接将不会生成三个动态库。同时ffplay和ffmpeg生成的执行文件也比较大,因为不需要动态库的支持就可以执行。但是不利于二次开发,所以我也可以考虑使用动态链接。
第二,编制
制造
第三,安装
进行安装
安装后,您将在/usr/local/ffmpeg中看到三个目录。
Lib动态链接库位置
包含编程使用头文件。
bin执行文件所在的目录。
为了方便以后编程,我们复制了三个链接库libavcodec。solibavformat。lib中的solibavuutil.so到/usr/lib。将include目录下的ffmpeg目录复制到/usr/include。在bin目录下执行ffplay,可以播放音频或者视频文件。例如,播放1.mp3
。/ffplay 1.mp3
此外,bin目录下还有两个文件:ffmpeg和ffserver。
Ffmpeg是一个很好的视频和音频格式转换工具。互联网上有很多关于它的文档。如果不想生成ffserver,只需添加-禁用-ffserver when即可。/configure。
注意:上面的/Developer/usr是目标目录。如果您的Xcode是默认安装的,您可以在Xcode中编译您的代码,并在安装后下载到模拟器中。
将价值转移到iPhone平台的过程:
一.配置
。/configure-enable-cross-compile-cross-prefix =/Developer/Platforms/iphone OS . platform/usr/bin/-cc =/Developer/Platforms/iphone OS . platform/Developer/usr/bin/arm-apple-Darwin 9-gcc-4 . 0 . 1-prefix =/Developer/Platforms/iphone OS . platform/Developer/SDKs/iphone OS 2.0 . SDK/usr-extra-cflags = "-isy root/Developer/Platforms/iphone OS . platform/platform
第二,编制
制造
第三,安装
进行安装
注:以上/开发者/平台/iphoneOS。platform/developer/usr/bin/是目标目录。如果您的Xcode是默认安装的,您可以在Xcode中编译您的代码,并在安装后下载到模拟器中。
相关说明:
如果在ffmpeg中使用静态库,会有一些连接错误。所以安装ffmpeg库的时候请选择动态库。
好了,现在我们知道怎么把ffmpeg搬到iPhone上,把ffmpeg库和Xcode结合起来。当然,如果你的Xcode工具不是默认安装的,请更改相关目录选项。