7

我正在尝试使用iFrameExtractor 示例中的 make 和 build 文件来编译 ffmpeg 。首先,我尝试遵循 github 上的自述文件,它只说要运行./build_universalffmpeg 文件夹。它不起作用

然后我尝试按照 INSTALL 中的信息进行操作,但没有成功。然后我尝试在 INSTALL 中做这些东西,然后是./build_universal哪个不起作用。导入到项目中的所有 *.a 文件都存在,直到构建序列结束。当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 4 构建。

4

3 回答 3

10

经过一周的反复试验,我终于能够创建 ffmpeg 通用库并成功编译和运行设备和模拟器的 iFrameExtractor。

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

1)打开终端

2)克隆存储库: git clone git://github.com/lajos/iFrameExtractor.git

3)进入项目中的ffmpeg文件夹:cd iFrameExtractor/ffmpeg

4)运行:./configure

5) 编辑构建脚本(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)构建ffmpeg库:./build_universal

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

这些步骤对我来说非常有效。我希望这将帮助其他努力让 ffmpeg 库适用于 iOS 的人。

于 2012-01-17T18:18:11.320 回答
5

我下载了最新的 ffmpeg 存储库并使用以下内容仅为 armv6 和 armv7 编译。我无法让它为 i386 工作,我收到 cputype 和 subcputype 错误的错误。显然 cputype 应该是 x86 而 subcputype 应该是 intel。

无论如何,我使用以下构建脚本来编译 arm 架构:

构建脚本:

#!/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 中构建!

于 2011-08-12T08:49:01.890 回答
1

为 iOS 5.1 构建 FFMPEG

希望这将帮助您为 iOS 5.1 构建最新的 FFMPEG

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

cd ffmpeg

./build_universal

注意:您必须先创建 build_* 脚本,要执行此操作,请参见下面的代码

ARMV7 脚本 - 创建文件 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_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_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_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/
于 2012-08-14T13:44:14.143 回答