编译 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(六)

要上班了,是否焦虑?

相关推荐
末代iOS程序员华仔13 小时前
Cursor + GitOps:自动化运维新姿势
flutter·ios·swift
世界尽头与你16 小时前
iOS 越狱检测原理
安全·网络安全·ios·信息安全·渗透测试
_瑞2 天前
AI Coding 那么快,为什么还需要 SDD?
人工智能·ios·ai编程
轩辕十四leo2 天前
Astrolabe(星盘):让 AI 看见自己写出的 UI
ios·ai编程
霸道流氓气质2 天前
视频预览链路三件套:ZLMediaKit · MediaMTX · FFmpeg 完全指南
ffmpeg·音视频
xgc_java2 天前
在Java里把ONNX/OpenCV/FFmpeg跑稳:28篇bytedeco实战小册完整指南
java·opencv·ffmpeg
白玉cfc2 天前
熟悉Objective-C
开发语言·ios·objective-c
星辰即远方2 天前
字符串合法性检验
macos·ios·cocoa
末代iOS程序员华仔2 天前
KMP全栈开发:从Android到AI Agent的技术演进与实践
flutter·ios·figma
2501_916008892 天前
苹果上架工具怎么选 不用 Mac 上架 App Store 的几种方案
android·macos·ios·小程序·uni-app·iphone·webview