为iFrameExtractor编译ffmpeg问题

我试图通过使用iFrameExtractor示例中的make和build文件来编译ffmpeg。 首先我试图按照github上的自述文件,它只是说在ffmpeg文件夹中运行./build_universal 。 它不起作用

然后我试图按照INSTALL中的信息没有成功。 然后,我试着在INSTALL中执行这些东西,然后是./build_universal ,这些都不起作用。 所有导入到项目的* .a文件都存在,直到构build序列结束。 当build_universal中的lipo命令运行时,我猜测不同体系结构(?)的.a文件。 无论如何,这些留下以下错误:

 lipo: specifed architecture type (armv6) for file (armv6/libavcodec.a) does not match it's cputype (16777223) and cpusubtype (3) (should be cputype (12) and cpusubtype (6)) lipo: specifed architecture type (armv6) for file (armv6/libavdevice.a) does not match it's cputype (16777223) and cpusubtype (3) (should be cputype (12) and cpusubtype (6)) lipo: specifed architecture type (armv6) for file (armv6/libavformat.a) does not match it's cputype (16777223) and cpusubtype (3) (should be cputype (12) and cpusubtype (6)) lipo: specifed architecture type (armv6) for file (armv6/libavutil.a) does not match it's cputype (16777223) and cpusubtype (3) (should be cputype (12) and cpusubtype (6)) lipo: specifed architecture type (armv6) for file (armv6/libswscale.a) does not match it's cputype (16777223) and cpusubtype (3) (should be cputype (12) and cpusubtype (6)) 

我可以得到项目编译模拟器,如果我只使用./build_armv7但如果我运行普遍的.a文件被删除在最后。 只有使用不能为iPhone 4build立工作。

经过一个星期的反复试验,我终于可以创buildffmpeg通用库,并成功编译和运行设备以及模拟器的iFrameExtractor。

在iPhone设备或模拟器上编译和运行项目:

1)打开terminal

2)克隆版本库:git clone git://github.com/lajos/iFrameExtractor.git

3)转到项目中的ffmpeg文件夹:cd iFrameExtractor / ffmpeg

4)运行:./configure

5)编辑构build脚本(build_armv6,build_armv7,build_i386),如下所示:

这些脚本假定您在Xcode 4.2上使用iOS SDK 5.0。

build_armv6:

 #!/bin/tcsh -f if (! -d armv6) mkdir armv6 if (! -d lib) mkdir lib rm armv6/*.a make clean ./configure \ --disable-bzlib --disable-doc \ --disable-ffmpeg --disable-ffplay \ --disable-ffserver --disable-mmx \ --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \ --as='gas-preprocessor/gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \ --enable-cross-compile --target-os=darwin \ --arch=arm --cpu=arm1176jzf-s \ --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk \ --extra-ldflags="-arch armv6 -L//Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/system" \ --extra-cflags="-arch armv6" make mv libavcodec/libavcodec.a armv6/ mv libavdevice/libavdevice.a armv6/ mv libavformat/libavformat.a armv6/ mv libavutil/libavutil.a armv6/ mv libswscale/libswscale.a armv6/ rm lib/*.a cp armv6/*.a lib/ 

build_armv7:

 #!/bin/tcsh -f if (! -d armv7) mkdir armv7 if (! -d lib) mkdir lib rm armv7/*.a make clean ./configure \ --disable-bzlib --disable-doc \ --disable-ffmpeg --disable-ffplay \ --disable-ffserver --disable-mmx \ --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \ --as='gas-preprocessor/gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \ --enable-cross-compile --target-os=darwin \ --arch=arm --cpu=cortex-a8 --enable-pic \ --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk \ --extra-ldflags="-arch armv7 - L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/system" \ --extra-cflags="-arch armv7" make mv libavcodec/libavcodec.a armv7/ mv libavdevice/libavdevice.a armv7/ mv libavformat/libavformat.a armv7/ mv libavutil/libavutil.a armv7/ mv libswscale/libswscale.a armv7/ rm lib/*.a cp armv7/*.a lib/ 

build_i386:

 #!/bin/tcsh -f if (! -d i386) mkdir i386 if (! -d lib) mkdir lib rm i386/*.a make clean ./configure \ --disable-bzlib --disable-doc \ --disable-ffmpeg --disable-ffplay \ --disable-ffserver --disable-mmx \ --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \ --as='gas-preprocessor/gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \ --sysroot=/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk \ --extra-ldflags="-arch i386 -L//Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/usr/lib/system" \ --extra-cflags="-arch i386 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -O0 -fasm-blocks -Wreturn-type -Wunused-variable -D__IPHONE_OS_VERSION_MIN_REQUIRED=40000 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -fvisibility=hidden -mmacosx-version-min=10.5 -gdwarf-2" make mv libavcodec/libavcodec.a i386/ mv libavdevice/libavdevice.a i386/ mv libavformat/libavformat.a i386/ mv libavutil/libavutil.a i386/ mv libswscale/libswscale.a i386/ rm lib/*.a cp i386/*.a lib/ 

6)build立ffmpeg库:./build_universal

7)打开xcode项目并在iPhone设备或模拟器上运行它

这些步骤完全适合我。 我希望这将帮助其他人努力获得适用于iOS的ffmpeg库。

我下载了最新的ffmpeg版本库,并使用下面的代码来编译armv6和armv7。 我不能得到它为i386工作,我收到错误,cputype和subcputype是错误的。 显然cputype应该是x86,subcputype应该是intel。

无论如何,我用下面的构build脚本来编译arm架构:

build立脚本:

 #!/bin/sh set -e SCRIPT_DIR=$( (cd -P $(dirname $0) && pwd) ) DIST_DIR_BASE=${DIST_DIR_BASE:="$SCRIPT_DIR/dist"} if [ -d ffmpeg ] then echo "Found ffmpeg source directory, no need to fetch from git..." else echo "Fetching ffmpeg from git://git.videolan.org/ffmpeg.git..." git clone git://git.videolan.org/ffmpeg.git fi ARCHS=${ARCHS:-"armv6 armv7"} for ARCH in $ARCHS do FFMPEG_DIR=ffmpeg-$ARCH if [ -d $FFMPEG_DIR ] then echo "Removing old directory $FFMPEG_DIR" rm -rf $FFMPEG_DIR fi echo "Copying source for $ARCH to directory $FFMPEG_DIR" cp -a ffmpeg $FFMPEG_DIR cd $FFMPEG_DIR DIST_DIR=$DIST_DIR_BASE-$ARCH mkdir -p $DIST_DIR case $ARCH in armv6) EXTRA_FLAGS="--enable-cross-compile --target-os=darwin --arch=arm --cpu=arm1176jzf-s" EXTRA_CFLAGS="-arch $ARCH" EXTRA_LDFLAGS="-arch $ARCH" ;; armv7) EXTRA_FLAGS="--enable-cross-compile --target-os=darwin --arch=arm --cpu=cortex-a8 --enable-pic" EXTRA_CFLAGS="-arch $ARCH" EXTRA_LDFLAGS="-arch $ARCH" ;; x86_64) EXTRA_CC_FLAGS="-mdynamic-no-pic" ;; esac echo "Configuring ffmpeg for $ARCH..." ./configure \ --prefix=$DIST_DIR \ --extra-ldflags=-L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/system \ --disable-bzlib \ --disable-doc \ --disable-ffmpeg \ --disable-ffplay \ --disable-ffserver \ --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \ --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk \ --extra-ldflags="$EXTRA_LDFLAGS" \ --extra-cflags="$EXTRA_CFLAGS" \ $EXTRA_FLAGS echo "Installing ffmpeg for $ARCH..." make && make install cd $SCRIPT_DIR if [ -d $DIST_DIR/bin ] then rm -rf $DIST_DIR/bin fi if [ -d $DIST_DIR/share ] then rm -rf $DIST_DIR/share fi done 

并结合libs脚本:

 #!/bin/bash set -e ARCHS="armv6 armv7" for ARCH in $ARCHS do if [ -d dist-$ARCH ] then MAIN_ARCH=$ARCH fi done if [ -z "$MAIN_ARCH" ] then echo "Please compile an architecture" exit 1 fi OUTPUT_DIR="dist-uarch" rm -rf $OUTPUT_DIR mkdir -p $OUTPUT_DIR/lib $OUTPUT_DIR/include for LIB in dist-$MAIN_ARCH/lib/*.a do LIB=`basename $LIB` LIPO_CREATE="" for ARCH in $ARCHS do if [ -d dist-$ARCH ] then LIPO_CREATE="$LIPO_CREATE-arch $ARCH dist-$ARCH/lib/$LIB " fi done OUTPUT="$OUTPUT_DIR/lib/$LIB" echo "Creating: $OUTPUT" lipo -create $LIPO_CREATE -output $OUTPUT lipo -info $OUTPUT done echo "Copying headers from dist-$MAIN_ARCH..." cp -R dist-$MAIN_ARCH/include/* $OUTPUT_DIR/include 

那么我从BUILD-FOLDER / dist-uarch中导入.a文件,它就像魅力一样在xcode中build立起来!

构buildiOS 5.1的FFMPEG

希望这会帮助你构buildiOS 5.1的最新FFMPEG

 git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg cd ffmpeg ./build_universal 

注意:你必须先创buildbuild_ *脚本,这样做看下面的代码

ARMV7脚本 – 创build文件build_armv7

 #!/bin/tcsh -f if (! -d armv7) mkdir armv7 if (! -d lib) mkdir lib rm armv7/*.a make clean ./configure --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --enable-cross-compile --arch=arm --target-os=darwin --cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc --as='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 --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' --enable-pic make mv libavcodec/libavcodec.a armv7/ mv libavdevice/libavdevice.a armv7/ mv libavformat/libavformat.a armv7/ mv libavutil/libavutil.a armv7/ mv libswscale/libswscale.a armv7/ rm lib/*.a cp armv7/*.a lib/ 

ARMV6脚本 – 创build文件build_armv6

 #!/bin/tcsh -f if (! -d armv6) mkdir armv6 if (! -d lib) mkdir lib rm armv6/*.a make clean ./configure --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --enable-cross-compile --arch=arm --target-os=darwin --cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc --as='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 --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' make mv libavcodec/libavcodec.a armv6/ mv libavdevice/libavdevice.a armv6/ mv libavformat/libavformat.a armv6/ mv libavutil/libavutil.a armv6/ mv libswscale/libswscale.a armv6/ rm lib/*.a cp armv6/*.a lib/ 

模拟器的脚本 – 创build文件build_i386

 #!/bin/tcsh -f if (! -d i386) mkdir i386 if (! -d lib) mkdir lib rm i386/*.a make clean ./configure \ --disable-bzlib --disable-doc \ --disable-ffmpeg --disable-ffplay \ --disable-ffserver --disable-mmx \ --cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \ --as='gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \ --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk \ --extra-ldflags="-arch i386 -L//Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/usr/lib/system" \ --extra-cflags="-arch i386 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -O0 -fasm-blocks -Wreturn-type -Wunused-variable -D__IPHONE_OS_VERSION_MIN_REQUIRED=40000 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk -fvisibility=hidden -mmacosx-version-min=10.5 -gdwarf-2" make mv libavcodec/libavcodec.a i386/ mv libavdevice/libavdevice.a i386/ mv libavformat/libavformat.a i386/ mv libavutil/libavutil.a i386/ mv libswscale/libswscale.a i386/ rm lib/*.a cp i386/*.a lib/ 

通用构build脚本(将库合并为一个通用) – 创build文件build_universal

 #!/bin/tcsh -f source ./build_armv6 source ./build_armv7 source ./build_i386 if (! -d universal) mkdir universal if (! -d lib) mkdir lib rm universal/*.a lipo -create -arch armv6 armv6/libavcodec.a -arch armv7 armv7/libavcodec.a -arch i386 i386/libavcodec.a -output universal/libavcodec.a lipo -create -arch armv6 armv6/libavdevice.a -arch armv7 armv7/libavdevice.a -arch i386 i386/libavdevice.a -output universal/libavdevice.a lipo -create -arch armv6 armv6/libavformat.a -arch armv7 armv7/libavformat.a -arch i386 i386/libavformat.a -output universal/libavformat.a lipo -create -arch armv6 armv6/libavutil.a -arch armv7 armv7/libavutil.a -arch i386 i386/libavutil.a -output universal/libavutil.a lipo -create -arch armv6 armv6/libswscale.a -arch armv7 armv7/libswscale.a -arch i386 i386/libswscale.a -output universal/libswscale.a rm lib/*.a cp universal/*.a lib/