iphone - 为armv6-7构建ffmpeg失败

标签 iphone ios ffmpeg compilation arm

我一直在尝试以我能想到的各种可能的方式构建 ffmpeg。我正在尝试使用他们的 git 存储库中的最新版本和构建脚本,我已确认它有效,它来自这个问题: iPhone SDK 4.3 libav compiling problem 。该脚本已于昨天更新,显然适用于问题中的人。

我的问题是它不会为armv6和armv7生成.a文件(或者实际上任何文件)。因此,连接到通用库的 lipo 命令会失败。我还尝试使用 iFrameExtractor 中的构建脚本如果没有任何成功,最后 lipo 命令也会失败,我得到以下信息:

lipo: can't open input file: ./compiled/armv6/lib/libavcodec.a (No such file or directory)
lipo: can't open input file: ./compiled/armv6/lib/libavdevice.a (No such file or directory)
lipo: can't open input file: ./compiled/armv6/lib/libavfilter.a (No such file or directory)
lipo: can't open input file: ./compiled/armv6/lib/libavformat.a (No such file or directory)
lipo: can't open input file: ./compiled/armv6/lib/libavutil.a (No such file or directory)
lipo: can't open input file: ./compiled/armv6/lib/libpostproc.a (No such file or directory)
lipo: can't open input file: ./compiled/armv6/lib/libswscale.a (No such file or directory)

我还发布了整个输出 here如果有人知道在那里寻找什么(因为我不知道从哪里开始,它几乎有 5000 行输出。) 我还应该提到,我正在为 armv6armv7i386 编译它。我想将其导入到 XCode 中以从视频源中获取 H.264 帧。

当我尝试构建armv6时,我使用以下配置:

./configure \
--enable-cross-compile \
--arch=arm \
--extra-cflags='-arch armv6' \
--extra-ldflags='-arch armv6' \
--target-os=darwin \
--cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
--sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk \
--cpu=arm1176jzf-s \
--extra-ldflags=-L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/usr/lib/system \
--prefix=compiled/armv6

并获得以下输出:

/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc is unable to create an executable file.
C compiler test failed.

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7e1818130e1b19530b0d1b0c3e1818130e1b1950110c19" rel="noreferrer noopener nofollow">[email protected]</a> mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "config.log" produced by configure as this will help
solving the problem.

那么问题来了,我应该使用什么c编译器?我尝试过不同的: ARM -苹果-darwin10-gcc-4.2.1 ARM -苹果-darwin10-llvm-gcc-4.2 海湾合作委员会

但结果相同。 gcc 适用于 i386 和 armv7,所以我想它也应该适用于 armv6

最佳答案

我使用以下代码仅针对armv6和armv7进行编译。我无法让它在 i386 上工作,我收到 cputype 和 subcputype 错误的错误。显然,cputype 应该是 x86,subcputype 应该是 intel。

无论如何,我使用以下构建脚本来编译arm架构(我最终使用了gcc并且它工作了,我猜这是配置标志从一开始就是错误的):

构建脚本:

#!/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

并结合库脚本:

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

关于iphone - 为armv6-7构建ffmpeg失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7007305/

相关文章:

javascript - 有没有办法使用 JavaScript 控制 iPod Touch 的键盘方向?

ios - 如何为 Uitextfield 设置最小和最大限制?

ios - swift 中的 NavigationController 导致黑屏

jquery - jQuery hover() 的第二个函数在 iOS 上不起作用

opencv - Delphi opencv ocvFFMpegIPCamSource 到位图?

c++ - FFmpeg AVPacket控件

iphone - 为什么当我添加属性时 CoreData 崩溃?

ios - 如何从放置在其他 TableView 单元格中的 TableView 单元格导航到 View Controller ?

ios - 如何将数据从先前的 segue 传递给 subview Controller ?

java processbuilder ffmpeg 管道