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

要上班了,是否焦虑?

相关推荐
悄然林静1 天前
Mac终端执行`brew doctor`报`openssl@1.1`警告
mac·xcode·apple
用户091 天前
SwiftUI Charts 函数绘图完全指南
ios·swiftui·swift
YungFan1 天前
iOS26适配指南之UIColor
ios·swift
权咚2 天前
阿权的开发经验小集
git·ios·xcode
用户092 天前
TipKit与CloudKit同步完全指南
ios·swift
法的空间2 天前
Flutter JsonToDart 支持 JsonSchema
android·flutter·ios
2501_915918412 天前
iOS 上架全流程指南 iOS 应用发布步骤、App Store 上架流程、uni-app 打包上传 ipa 与审核实战经验分享
android·ios·小程序·uni-app·cocoa·iphone·webview
00后程序员张2 天前
iOS App 混淆与加固对比 源码混淆与ipa文件混淆的区别、iOS代码保护与应用安全场景最佳实践
android·安全·ios·小程序·uni-app·iphone·webview
Magnetic_h3 天前
【iOS】设计模式复习
笔记·学习·ios·设计模式·objective-c·cocoa
00后程序员张3 天前
详细解析苹果iOS应用上架到App Store的完整步骤与指南
android·ios·小程序·https·uni-app·iphone·webview