在Mac OS 10.8上安装适用于armv7、armv7s、i386和通用型的iOS ffmpeg库

7

我该如何在Mac OS 10.8上安装最新的ffmpeg ios库,包括armv7、armv7s、i386和通用版本?


https://dev59.com/pmEh5IYBdhLWcg3wIgQX - Tarun Seera
请参考此帖的 Github 代码库,它会对您有所帮助: https://dev59.com/dnfZa4cB1Zd3GeqPXuod#46245639 - Prabhat Kasera
4个回答

19

几天后,我为此安装制作了逐步说明:

在MAC 10.8或更高版本中构建FFmpeg的说明:

复制ffmpeg-2.0.tar.bz2 (https://ffmpeg.org/releases/ffmpeg-1.0.7.tar.bz2, https://ffmpeg.org/download.html)并将其解压到文档文件夹

确保您拥有最新版本的Xcode命令行工具 >; 首选项 >; 下载 >; 组件

安装gas-preprocessor

  1. 单击ZIP图标下载https://github.com/mansr/gas-preprocessor
  2. 将gas-preprocessor.pl复制到/usr/bin目录中
  3. 通过设置所有用户的读写特权来更改gas-preprocessor.pl的权限

版本10.8中xcrun中存在错误

打开终端并粘贴以下命令,然后按Enter键:

export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer/"

进入ffmpeg-2文件夹并粘贴以下命令,然后按Enter键:

mkdir armv7
mkdir armv7s
mkdir i386
mkdir -p universal/lib

要配置armv7s库,请粘贴以下命令并按Enter键:

./configure --prefix=armv7s --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --enable-avresample --enable-cross-compile --sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk" --target-os=darwin --cc="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc" --extra-cflags="-arch armv7s -mfpu=neon -miphoneos-version-min=6.1" --extra-ldflags="-arch armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk -miphoneos-version-min=6.1" --arch=arm --cpu=cortex-a9 --enable-pic

(注意与上面相同的规则:如果配置失败,请前往Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/,确保sdk文件夹为iPhoneOS6.1.sdk,如果不是,请更改配置命令以反映iPhoneOSx.x.sdk,并将所有目标更改为x.x)

要构建和安装armv7s库,请粘贴以下命令并按Enter键:

make clean && make && make install

要配置i386(以便模拟器正常工作),请粘贴以下命令并按Enter键:

./configure --prefix=i386 --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --enable-avresample --enable-cross-compile --sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk" --target-os=darwin --cc="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc" --extra-cflags="-arch i386" --extra-ldflags="-arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk" --arch=i386 --cpu=i386 --enable-pic --disable-asm

(注意:这不是与前两个配置命令相同的命令,如果你只是向上箭头找它们,这将失败)

为了构建和安装i386库,请粘贴以下命令并按回车键:

make clean && make && make install

要创建通用库(即添加到Xcode的库),请粘贴以下命令并按Enter键:

cd armv7/lib
for file in *.a
do
cd ../..
xcrun -sdk iphoneos lipo -output universal/lib/$file  -create -arch armv7 armv7/lib/$file -arch armv7s armv7s/lib/$file -arch i386 i386/lib/$file
echo "Universal $file created."
cd -
done
cd ../..

1
将代码进行格式化,可以使其更易于阅读。您可以选中文本并按Ctrl+K或Command+K(我想是这样),或者点击文本框上方类似于{}的代码按钮。 - llogan
你能添加对iOS7的支持吗? - ppaulojr
我尝试使用来自https://ffmpeg.org/releases/的ffmpeg2.2和来自https://github.com/michaelni/gas-preprocessor的gas预处理器进行上述指令,但是我只得到了静态库文件(我能从中创建可执行文件吗?)而且我看不到ffmpeg在哪里...?我应该从configure中删除disable-ffmpeg吗? 您能详细说明每个参数的含义吗? 如果我只想将一个音频文件格式转换为另一个格式?(或者将立体声合并为单声道?)我应该使用什么设置来配置上面的脚本?我希望二进制输出尽可能小... - Itay Levin

16

支持iOS7和XCode5的通用ffmpeg库:

确保您拥有最新的Command Line Tools,路径为Xcode >; Preferences >; Downloads >; Components

安装gas-preprocessor

  1. 点击ZIP图标下载https://github.com/mansr/gas-preprocessor.
  2. 将gas-preprocessor.pl复制到/usr/bin目录。
  3. 通过将特权设置为所有用户读写权限来更改gas-preprocessor.pl的权限。

https://gist.github.com/m1entus/6983547下载我的shell脚本。

  1. 运行sh build-ffmpeg.sh

1
太棒了,我花了很多时间在这上面。 :D - duongvanthai
请确保运行此脚本的目录路径不包含空格。 - Nikolay Shubenkov
3
我遇到了这个错误 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc 无法创建可执行文件。C 编译器测试失败。 在 Xcode5 中 GCC 已被弃用,我不太确定接下来该怎么做。 - Joseph Toronto
1
请确保您在Xcode >; 首选项 >; 下载 >; 组件下安装了最新的命令行工具。 - Michal Zaborowski
太棒了,节省了我很多时间。谢谢。 - Vincent Sit
1
我也遇到了Joseph Toronto问题,而且我似乎正在使用最新的5.1.1命令行工具。我可以选择4.x和5.x。 - Sasho

2
我需要 arm64 支持,这个脚本对我很有用:https://github.com/kewlbear/FFmpeg-iOS-build-script 使用:
./build-ffmpeg.sh arm64 x86_64

针对iOS的64位和模拟器架构。然后将“fat”目录中的内容复制到您的Xcode项目中。

我所做的唯一修改是取消注释此行:

CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-avresample"

编译libavresample库。

编辑:使用iOS 7.1 SDK时,它不能与armv7和armv7s一起工作。如果我找到解决方案,我会在这里发布。


你不应该只是在命令行脚本中添加armv7和armv7s吗? - Itay Levin

1

要构建ffmpeg iOS库,您可以使用这个小脚本

  1. 下载ffmpeg源代码
  2. 下载https://github.com/wang-bin/build_ffmpeg
  3. 打开终端并运行export FFSRC=/path/to/ffmpeg
  4. 进入build_ffmpeg文件夹并运行:./ios.sh
  5. 成功构建后,结果将在sdk-ios文件夹中
  6. 将include文件夹和lib文件夹添加到您的Xcode项目中

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接