ios 适用于 iOS5 的 FFmpeg
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8323672/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
FFmpeg for iOS5
提问by brad_roush
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.
有没有人能够使用 iOS5 sdk 编译 ffmpeg 库?我找到了使用 4.3 sdk 但没有用于 iOS5 的脚本。我认为用旧的 sdk 和 armv7 构建的库仍然兼容 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/
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.
我还尝试切换到 gcc-4.2 以及 llvm-gcc-4.2。但是,我在评论中看到下面显示的“未知选项”错误。
Any info will be great and thanks.
任何信息都会很棒,谢谢。
回答by mattjgalloway
UPDATED:Completely changed the answer to use the script that I use.
更新:完全改变了使用我使用的脚本的答案。
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.
你也将需要下载gas-preprocessor.pl
的https://github.com/yuvi/gas-preprocessor
,把它放在你的路径,并使其可执行。
Then create a script (say make_for_iphone.sh
) and put this in it:
然后创建一个脚本(例如make_for_iphone.sh
)并将其放入其中:
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
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
.
这会编译 armv6 和 armv7 版本,并使用lipo
. 它安装到您从名为installed
.
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.
需要注意的是,此刻我已经过了关内联汇编使用perl
内联替换,以改变HAVE_INLINE_ASM
从1
到0
。这是因为gas-preprocessor.pl
- https://github.com/yuvi/gas-preprocessor/issues/16的这个问题。
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.
另请注意,这关闭了除 H264 解码器之外的所有编码器、解码器、复用器、解复用器等。只需更改配置行即可为您的用例编译您想要的内容。
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.
另请记住,这已启用 GPL 代码 - 因此您应该了解这对 iPhone 应用程序意味着什么。如果你不知道那么你应该做一些阅读。
回答by dalexsoto
Here is my working Configure for cross-compiling FFmpeg
on iOS 6 the arch is ARMv7
这是我FFmpeg
在 iOS 6 上进行交叉编译的工作配置,arch 是ARMv7
NOTE: You must have to have gas-preprocessor.plinside /usr/local/bin/
please do not continue until you have gas-preprocessor.plon your bin directory
注意:你必须在里面有gas-preprocessor.pl/usr/local/bin/
请不要继续,直到你的 bin 目录中有gas-preprocessor.pl
Download FFmpeg 1.0 "Angel" from here
Unzip it and place it somewhere i.e. your
Desktop
folderOpen terminal and browse to
unzipped FFmpeg folder
Copy and paste the following command, (be patient will take a while)
从这里下载 FFmpeg 1.0“天使”
解压缩并将其放在某个地方,即您的
Desktop
文件夹打开终端并浏览到
unzipped FFmpeg folder
复制并粘贴以下命令,(请耐心等待一段时间)
./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/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/iPhoneOS6.0.sdk --cpu=cortex-a8 --extra-cflags='-arch armv7' --extra-ldflags='-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk' --enable-pic --enable-decoder=rawvideo --disable-asm
./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/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/iPhoneOS6.0.sdk --cpu=cortex-a8 --extra- cflags='-arch armv7' --extra-ldflags='-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk' --enable- pic --enable-decoder=rawvideo --disable-asm
Now type the following command on terminal
make
(wait a little more)Once it has finished now type on terminal
sudo make install
(wait again)Go to
/usr/local/lib
to find your freshly bakedarmv7
libsEnjoy!
现在在终端上输入以下命令
make
(再等一会儿)一旦完成,现在在终端上输入
sudo make install
(再次等待)去
/usr/local/lib
寻找你新鲜出炉的armv7
库享受!
Alex
亚历克斯
回答by ciphor
I've created an "ffmpeg4ios" project at https://github.com/ciphor/ffmpeg4ios, which is successfully compiled on iOS 5.0. You can check it.
我在https://github.com/ciphor/ffmpeg4ios创建了一个“ffmpeg4ios”项目,它在 iOS 5.0 上成功编译。你可以检查一下。