编译 x264 for iOS

文章目录


环境 :

macOS 14.3.1

x264 - 20191217-2245


编译

1、下载 x264 源码

http://download.videolan.org/pub/videolan/x264/snapshots/

这里我下载x264-snapshot-20191217-2245.tar.bz2 (截止2024-05-04最新)

解压后,将文件夹命名为 x264 (编译脚本写死这个地址)


2、下载 x264 编译脚本
https://github.com/kewlbear/x264-ios

将脚本和源码 x264 放在同一级目录


3、编译 x264

这里我将脚本中的 ARCHS 选项只保留 arm64 x86_64,然后执行

shell 复制代码
./build-x264.sh

编译完将生成 x264-iOS 文件夹

shell 复制代码
% cd /Users/shushu/Downloads/x264/x264-iOS 
% tree
.
├── include
│   ├── x264.h
│   └── x264_config.h
└── lib
    └── libx264.a

在 FFMpeg 启用 x264


修改 ffmpeg 编译脚本

对于 <目前大家都是用这份脚本

https://github.com/kewlbear/FFmpeg-iOS-build-script\> 的 ./build-ffmpeg.sh 文件

1、17 行的注释打开

sh 复制代码
X264=`pwd`/fat-x264

在 脚本同一级目录,新建文件夹命名为 fat-x264,将 x264 编译出来的 x264-iOS 文件夹下的 lib 复制到 fat-x264 下。
x264-iOS保持还不懂,后续会拖放到 iOS 工程中。


2、将 104行的 -fembed-bitcode 去掉

sh 复制代码
CFLAGS="$CFLAGS -mios-version-min=$DEPLOYMENT_TARGET -fembed-bitcode"

修改为

sh 复制代码
CFLAGS="$CFLAGS -mios-version-min=$DEPLOYMENT_TARGET"

其他编译选项


  • To build everything:
shell 复制代码
./build-x264.sh

  • To build for arm64:
shell 复制代码
./build-x264.sh arm64

  • To build fat library for armv7 and x86_64 (64-bit simulator):
shell 复制代码
./build-x264.sh armv7 x86_64

  • To build fat library from separately built thin libraries:
shell 复制代码
./build-x264.sh lipo

  • Library and Header Files are in ./x264-iOS

报错处理

shellsh 复制代码
building x86_64...
Found no assembler
Minimum version is nasm-2.13
If you really want to compile without asm, configure with --disable-asm.

CONFIGURE_FLAGS 键添加选项 --disable-asm

不知道这个 未来是否会用上,先这么做


sh 复制代码
brew upgrade nasm 

伊织 2024-05-04(六)

要上班了,是否焦虑?

相关推荐
YungFan24 分钟前
iOS26适配指南之通知
ios·swift
木叶丸1 小时前
跨平台方案该如何选择?
android·前端·ios
Little_Code1 小时前
uniapp 使用ffmpeg播放rtsp
ffmpeg·uni-app·rtsp
伊成1 小时前
Mac中如何Chrome禁用更新[update chflags macos]
chrome·mac
我唔知啊2 小时前
OC底层原理二:OC对象的分类(实例对象、类对象、元类对象)
ios·objective-c
泓博3 小时前
KMP(Kotlin Multiplatform)改造(Android/iOS)老项目
android·ios·kotlin
Digitally3 小时前
如何将信息从 iPhone 同步到Mac(完整步骤和示意图)
macos·ios·iphone
大猫会长3 小时前
使用Mac自带的图像捕捉导出 iPhone 相册
ios·iphone
二流小码农10 天前
鸿蒙开发:基于node脚本实现组件化运行
android·ios·harmonyos