适用于 iOS5 的 FFmpeg [英] FFmpeg for iOS5

查看:13
本文介绍了适用于 iOS5 的 FFmpeg的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人能够使用 iOS5 sdk 编译 ffmpeg 库?我找到了使用 4.3 sdk 但没有用于 iOS5 的脚本.我认为用旧的 sdk 和 armv7 构建的库仍然兼容 iOS 5.

Has anyone been able to compile ffmpeg libraries using the iOS5 sdk? I have found scripts that use the 4.3 sdk but nothing for iOS5. I would assume that libraries built with the old sdk and armv7 will still be compatible for iOS 5.

这是我尝试使用的命令:

Here is the command I am trying to use:

./configure  --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc  --as='gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc'  --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk  --extra-ldflags=-L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/system  --target-os=darwin  --arch=arm  --cpu=cortex-a8  --extra-cflags='-arch armv7'  --extra-ldflags='-arch armv7'  --prefix=compiled/armv7  --enable-pic  --enable-cross-compile  --disable-armv5te  --disable-ffmpeg  --disable-ffplay  --disable-ffserver  --disable-ffprobe  --disable-doc

我也尝试过使用这样的脚本:

I have also tried using a script like this one:

#!/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=/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/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk --cpu=cortex-a8 --extra-cflags='-arch armv7' --extra-ldflags='-arch armv7' --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/

我也尝试切换到 gcc-4.2 和 llvm-gcc-4.2.但是,我在评论中看到下面显示的未知选项"错误.

I have also tried to switch to the gcc-4.2 as well as the llvm-gcc-4.2. However I get an "Unknown option" error shown below in the comments.

任何信息都会很棒,谢谢.

Any info will be great and thanks.

推荐答案

UPDATED: 完全改变了答案以使用我使用的脚本.

UPDATED: Completely changed the answer to use the script that I use.

你还需要从 https://github.com/yuvi/gas-preprocessor 下载 gas-preprocessor.pl,把它放在你的路径中并制作它可以执行.

You will also need to download gas-preprocessor.pl from https://github.com/yuvi/gas-preprocessor, put it in your path and make it executable.

然后创建一个脚本(比如make_for_iphone.sh)并将其放入其中:

Then create a script (say make_for_iphone.sh) and put this in it:

export PLATFORM="iPhoneOS"
export MIN_VERSION="4.0"
export MAX_VERSION="5.0"
export DEVROOT=/Developer/Platforms/${PLATFORM}.platform/Developer
export SDKROOT=$DEVROOT/SDKs/${PLATFORM}${MAX_VERSION}.sdk
export CC=$DEVROOT/usr/bin/llvm-gcc
export LD=$DEVROOT/usr/bin/ld
export CPP=$DEVROOT/usr/bin/cpp
export CXX=$DEVROOT/usr/bin/llvm-g++
export AR=$DEVROOT/usr/bin/ar
export LIBTOOL=$DEVROOT/usr/bin/libtool
export NM=$DEVROOT/usr/bin/nm
export CXXCPP=$DEVROOT/usr/bin/cpp
export RANLIB=$DEVROOT/usr/bin/ranlib

COMMONFLAGS="-pipe -gdwarf-2 -no-cpp-precomp -isysroot ${SDKROOT} -marm -fPIC"
export LDFLAGS="${COMMONFLAGS} -fPIC"
export CFLAGS="${COMMONFLAGS} -fvisibility=hidden"
export CXXFLAGS="${COMMONFLAGS} -fvisibility=hidden -fvisibility-inlines-hidden"

FFMPEG_LIBS="libavcodec libavdevice libavformat libavutil libswscale"

echo "Building armv6..."

make clean
./configure 
    --cpu=arm1176jzf-s 
    --extra-cflags='-arch armv6 -miphoneos-version-min=${MIN_VERSION} -mthumb' 
    --extra-ldflags='-arch armv6 -miphoneos-version-min=${MIN_VERSION}' 
    --enable-cross-compile 
    --arch=arm 
    --target-os=darwin 
    --cc=${CC} 
    --sysroot=${SDKROOT} 
    --prefix=installed 
    --disable-network 
    --disable-decoders 
    --disable-muxers 
    --disable-demuxers 
    --disable-devices 
    --disable-parsers 
    --disable-encoders 
    --disable-protocols 
    --disable-filters 
    --disable-bsfs 
    --enable-decoder=h264 
    --enable-decoder=svq3 
    --enable-gpl 
    --enable-pic 
    --disable-doc
perl -pi -e 's/HAVE_INLINE_ASM 1/HAVE_INLINE_ASM 0/' config.h
make -j3

mkdir -p build.armv6
for i in ${FFMPEG_LIBS}; do cp ./$i/$i.a ./build.armv6/; done

echo "Building armv7..."

make clean
./configure 
    --cpu=cortex-a8 
    --extra-cflags='-arch armv7 -miphoneos-version-min=${MIN_VERSION} -mthumb' 
    --extra-ldflags='-arch armv7 -miphoneos-version-min=${MIN_VERSION}' 
    --enable-cross-compile 
    --arch=arm 
    --target-os=darwin 
    --cc=${CC} 
    --sysroot=${SDKROOT} 
    --prefix=installed 
    --disable-network 
    --disable-decoders 
    --disable-muxers 
    --disable-demuxers 
    --disable-devices 
    --disable-parsers 
    --disable-encoders 
    --disable-protocols 
    --disable-filters 
    --disable-bsfs 
    --enable-decoder=h264 
    --enable-decoder=svq3 
    --enable-gpl 
    --enable-pic 
    --disable-doc
perl -pi -e 's/HAVE_INLINE_ASM 1/HAVE_INLINE_ASM 0/' config.h
make -j3

mkdir -p build.armv7
for i in ${FFMPEG_LIBS}; do cp ./$i/$i.a ./build.armv7/; done

mkdir -p build.universal
for i in ${FFMPEG_LIBS}; do lipo -create ./build.armv7/$i.a ./build.armv6/$i.a -output ./build.universal/$i.a; done

for i in ${FFMPEG_LIBS}; do cp ./build.universal/$i.a ./$i/$i.a; done

make install

这会编译 armv6 和 armv7 版本,并使用 lipo 将它们放入一个胖库中.它安装到您从名为 installed 运行脚本的文件夹下.

This compiles both armv6 and armv7 versions and puts them into a fat library using lipo. It installs to a folder underneath where you run the script from called installed.

请注意,目前我不得不使用 perl 内联替换关闭内联汇编以将 HAVE_INLINE_ASM1 更改为 <代码>0.这是因为 gas-preprocessor.pl 存在这个问题 - https://github.com/yuvi/gas-preprocessor/issues/16.

Note that at the moment I've had to turn off inline assembly using a perl inline replace to change HAVE_INLINE_ASM from 1 to 0. This is because of this problem with gas-preprocessor.pl - https://github.com/yuvi/gas-preprocessor/issues/16.

另请注意,这关闭了除 H264 解码器之外的所有编码器、解码器、复用器、解复用器等.只需更改配置行即可为您的用例编译所需内容.

Also note that this has turned off all encoders, decoders, muxers, demuxers, etc except for the H264 decoder. Just change the configure lines to compile what you want for your use case.

还请记住,这已启用 GPL 代码 - 因此您应该了解这对 iPhone 应用程序意味着什么.如果您不知道,那么您应该阅读一些相关资料.

Please remember also that this has enabled GPL code - so you should be aware about what that means for iPhone apps. If you're not aware then you should do some reading about that.

这篇关于适用于 iOS5 的 FFmpeg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆