源码地址
bilibili-ijkplayer
1.环境配置
首先检查brew
git
yasm
pkg-config
是否安装,没有的话,先安装
brew -v
git --version
yasm --version
pkg-config --verison
安装homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安装git
brew install git
安装yasm
brew install yasm
安装pkg-config
brew install pkg-config
2.编译配置
下载源码,并按照教程切换分支
git clone https://github.com/Bilibili/ijkplayer.git ijkplayer-ios
cd ijkplayer-ios
git checkout -B latest k0.8.8
配置编解码器格式支持
module-default.sh 更多的编解码器/格式
module-lite-hevc.sh 较少的编解码器/格式(包括hevc)
module-lite.sh 较少的编解码器/格式(默认情况)
# 进入 config 目录
cd config
# 删除当前的 module.sh 文件
rm module.sh
# 可根据需要替换为`module-default.sh`, `module-lite-hevc.sh`, `module-lite.sh`
# 创建软链接 module.sh 指向 module-lite-hevc.sh
ln -s module-lite-hevc.sh module.sh
cd ..
cd ios
sh compile-ffmpeg.sh clean
下载ffmpeg
cd ..
./init-ios.sh
3.直接编译ffmpeg
(需要支持https,直接跳过,进入第4步)
cd ios
./compile-ffmpeg.sh clean
./compile-ffmpeg.sh all
如果报错unknown directive .arch armv7-a
,则去需要将compile-ffmpeg.sh
中的第24行
FF_ALL_ARCHS_IOS8_SDK="armv7 arm64 i386 x86_64"
改成
FF_ALL_ARCHS_IOS8_SDK="arm64 i386 x86_64"
第120行
if [ "$FF_TARGET" = "armv7" -o "$FF_TARGET" = "armv7s" -o "$FF_TARGET" = "arm64" ]; then
改成
if [ "$FF_TARGET" = "armv7s" -o "$FF_TARGET" = "arm64" ]; then
4.添加 https 支持(如果不要,执行第3步就好)
最后会生成支持 https 的静态文件 libcrypto.a 和 libssl.a, 如果不需要可以跳过这一步
# 获取 openssl 并初始化
./init-ios-openssl.sh
# 在模块文件中添加一行配置 以启用 openssl 组件
cd ios
echo 'export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-openssl"' >> ../config/module.sh
编译 openssl
cd config
rm module.sh
ln -s module-default.sh module.sh
cd ../
./init-ios.sh
./init-ios-openssl.sh
cd ios
./compile-openssl.sh clean
./compile-ffmpeg.sh clean
./compile-openssl.sh all
./compile-ffmpeg.sh all
网友评论