美文网首页
【iOS】Xcode 12打包IJKMediaFramework

【iOS】Xcode 12打包IJKMediaFramework

作者: 酷酷的小虎子 | 来源:发表于2020-11-06 15:16 被阅读0次

问题前提:
新公司项目用到 ijkplayer 进行直播业务的播放,接手项目后有个业务需求对拉流延迟要求比较高,经过一系列 debug 后发现 iOS 端 ijkplayer 延迟略大于 Android 端,于是决定对 ijkplayer 的高延迟问题进行调优

前面的准备工作在这里不做赘述,在编译 ffmpeg 时(执行./compile-ffmpeg.sh all)时会有报错,如下:

./libavutil/arm/asm.S:44:9: error: unknown directive
        .arch armv7-a
        ^
./libavutil/arm/asm.S:57:9: error: unknown directive
        .fpu neon
        ^
make: *** [libavcodec/arm/aacpsdsp_neon.o] Error 1
make: *** Waiting for unfinished jobs....

ijkplayer 的编译、打包 framework 和 https 支持这篇文章中讲述最新的 Xcode 生成二进制包所支持的指令集排除了armv7,并提供了解决方案,大家可以参考,我尝试了一下确实可行。

鉴于我们项目目前支持的指令集包括armv7,所以我尝试了其他方法解决这个错误,我尝试了旧版 Xcode 尝试无果(最新的 macOS 也不支持下载过老的 Xcode 版本)。最后找到如下的解决方案:
/iOS/tools/do-compile-ffmpeg.sh

将
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $FFMPEG_CFG_FLAGS_ARM"
修改为
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --enable-pic --disable-asm"

然后重新执行

./compile-ffmpeg.sh all

这样我们再打开IJKMediaDemo项目就可以运行起来了

其他问题

问题1:
运行IJKMediaDemo报错如下:

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_IJKFFOptions", referenced from:
      objc-class-ref in IJKMoviePlayerViewController.o
  "_OBJC_CLASS_$_IJKFFMoviePlayerController", referenced from:
      objc-class-ref in IJKMoviePlayerViewController.o
  "_IJKMPMoviePlayerLoadStateDidChangeNotification", referenced from:
      -[IJKVideoViewController installMovieNotificationObservers] in IJKMoviePlayerViewController.o
      -[IJKVideoViewController removeMovieNotificationObservers] in IJKMoviePlayerViewController.o
  "_IJKMPMoviePlayerPlaybackDidFinishReasonUserInfoKey", referenced from:
      -[IJKVideoViewController moviePlayBackDidFinish:] in IJKMoviePlayerViewController.o
  "_IJKMPMoviePlayerPlaybackDidFinishNotification", referenced from:
      -[IJKVideoViewController installMovieNotificationObservers] in IJKMoviePlayerViewController.o
      -[IJKVideoViewController removeMovieNotificationObservers] in IJKMoviePlayerViewController.o
  "_IJKMPMediaPlaybackIsPreparedToPlayDidChangeNotification", referenced from:
      -[IJKVideoViewController installMovieNotificationObservers] in IJKMoviePlayerViewController.o
      -[IJKVideoViewController removeMovieNotificationObservers] in IJKMoviePlayerViewController.o
  "_IJKMPMoviePlayerPlaybackStateDidChangeNotification", referenced from:
      -[IJKVideoViewController installMovieNotificationObservers] in IJKMoviePlayerViewController.o
      -[IJKVideoViewController removeMovieNotificationObservers] in IJKMoviePlayerViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

解决办法:
Build Phases - Link Binary With Libraries - "+",添加IJKMediaFramework.framework,再次运行就可以运行成功了(模拟器运行即可)


未完待续...

相关文章

网友评论

      本文标题:【iOS】Xcode 12打包IJKMediaFramework

      本文链接:https://www.haomeiwen.com/subject/bdttmktx.html