ijkplayer集成

一、環(huán)境準(zhǔn)備

Mac系統(tǒng)版本:12.0.1 (21A559)
Xcode版本:13.1 (13A1030d)

brew --version
git --version
yasm --version
pkg-config --version

未完成安裝的,安裝下所缺少的

  • 安裝brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • 卸載brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
  • 使用brew安裝git
brew install git
  • 使用brew安裝 yasm
brew install yasm
  • 使用brew 安裝 pkg-config
brew install pkg-config

完成后


二、下載ffmpeg

  1. 克隆倉(cāng)庫(kù)到本地
//克隆倉(cāng)庫(kù)到指定位置并重命名為ijkplayer-ios
git clone https://github.com/Bilibili/ijkplayer.git ijkplayer-ios
  1. 新增一個(gè)本地分支(可選項(xiàng))
git checkout -B latest k0.8.8
  1. 下載ffmpeg(常見(jiàn)錯(cuò)誤見(jiàn)下面錯(cuò)誤錦集)
./init-ios.sh
  1. 下載成功后進(jìn)入ios文件夾
cd ios

三、編譯 fffmpeg

./compile-ffmpeg.sh clean
./compile-ffmpeg.sh clean 執(zhí)行成功
./compile-ffmpeg.sh all 

編譯過(guò)程中可能會(huì)出現(xiàn) error2

./compile-ffmpeg.sh a執(zhí)行成功

四、打包framework

  1. 打開ios/IJKMediaPlayer并運(yùn)行
  2. 調(diào)整target


  3. 調(diào)整運(yùn)行模式


  4. 分別編譯模擬器和真機(jī)
    編譯成功之后command + ,前往xcode設(shè)置頁(yè) ?? Lications ?? Derived Data ?? IJKMediaPlayer-xxx ?? Build ?? Products

cdProducts文件夾下合并真機(jī)和模擬器的framework
執(zhí)行命令: lipo -create 真機(jī)framework路徑 模擬器framework路徑 -output 合并的文件路徑

lipo -create Release-iphoneos/IJKMediaFramework.framework/IJKMediaFramework Release-iphonesimulator/IJKMediaFramework.framework/IJKMediaFramework -output IJKMediaFramework

執(zhí)行成功后Products文件夾下會(huì)生成 IJKMediaFramework

五、集成framework

錯(cuò)誤錦集

error1

Cloning into 'ios/ffmpeg-x86_64'...
fatal: unable to access 'https://github.com/Bilibili/FFmpeg.git/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
tools/pull-repo-ref.sh: line 11: cd: ios/ffmpeg-x86_64: No such file or directory
./init-ios.sh: line 64: cd: ios/ffmpeg-x86_64: No such file or directory
Cloning into 'ios/ffmpeg-i386'...
fatal: unable to access 'https://github.com/Bilibili/FFmpeg.git/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
tools/pull-repo-ref.sh: line 11: cd: ios/ffmpeg-i386: No such file or directory
./init-ios.sh: line 64: cd: ios/ffmpeg-i386: No such file or directory

這個(gè)問(wèn)題是無(wú)法鏈接Bilibili服務(wù)器,搞了大半天,最后還是用手機(jī)熱點(diǎn)才下載成功!建議切換網(wǎng)絡(luò)多試幾次

error2

AS  libavcodec/arm/aacpsdsp_neon.o
CC  libavcodec/arm/blockdsp_init_arm.o
./libavutil/arm/asm.S:50:9: error: unknown directive
        .arch armv7-a
        ^
make: *** [libavcodec/arm/aacpsdsp_neon.o] Error 1
make: *** Waiting for unfinished jobs....
clang: warning: optimization flag '-fomit-frame-pointer' is not supported for target 'armv7' [-Wignored-optimization-argument]

最新的 Xcode 已經(jīng)弱化了對(duì) 32 位的支持, 解決方法:
compile-ffmpeg.sh 中刪除 armv7 ,
修改前后對(duì)如下

修改1.png

修改2.png
修改3.png

修改之后,再重新執(zhí)行出現(xiàn)錯(cuò)誤的命令: ./compile-ffmpeg.sh all

error 3

The linked library 'libavcodec.a' is missing one or more architectures required by this target: armv7.

xcode12之后 編譯真機(jī)的時(shí)候會(huì)出現(xiàn)該錯(cuò)誤
解決思路是在Target?? Build Settings ??Excluded Architectures中添加以下代碼,添加之后重新編譯一次

EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64=arm64 arm64e armv7 armv7s armv6 armv8 EXCLUDED_ARCHS=$(inherited) $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_$(EFFECTIVE_PLATFORM_SUFFIX)__NATIVE_ARCH_64_BIT_$(NATIVE_ARCH_64_BIT))

error4
執(zhí)行合并framework時(shí)可能會(huì)報(bào)錯(cuò)

Release-iphoneos/IJKMediaFramework.framework/IJKMediaFramework and Release-iphonesimulator/IJKMediaFramework.framework/IJKMediaFramework have the same architectures (arm64) and can't be in the same fat output file

解決方案
設(shè)置 Build Setting ?? Excluded Architectures ??Debug ??添加上 arm64
設(shè)置 Build Setting ?? Excluded Architectures ??Release ??添加上 arm64
出現(xiàn)的原因是XCode12 編譯的模擬器庫(kù)新增支持架構(gòu)arm64。將模擬器的arm64給排除出去即可。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容