問題描述
有沒有人能夠使用 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: 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_ASM
從 1
更改為 <代碼>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的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!