ubuntu 使用mingw-w64-x86交叉编译windows ffmpeg

需要的资源

(1)交叉编译脚本cross_compile_ffmpeg.sh
(2)能让你直连下载git的工具

安装环境准备

首次运行cross_compile_ffmpeg.sh 会提示需要安装各种依赖包,主要有以下依赖包:

  1. python3>=3.6
  2. meson>=0.49.2
  3. yasm>=1.2.0
  4. cmake>=3.0
  5. 其他提示需要的安装包,我本人测试用的ubuntu5.4,版本很老,还额外安装的很多依赖包(lsb_release等等).

额外需要的工具

因为交叉编译脚本cross_compile_ffmpeg.sh 都是使用git curl从项目地址拉取版本使用,因此需要用到直连工具.并且手头需要可用的直连客户端配置信息.

编译设置

可以通过 ./cross_compile_ffmpeg.sh --help获取,主要参数是:

--build-ffmpeg-static=y(默认)
--build-ffmpeg-shared=y

另外对于 编译脚本cross_compile_ffmpeg.sh中,curl 下载失败提示 handshake_failed()
可以修改 line 664:download_and_unpack_file() 中的

 curl -4 "$url"

curl --socks5 127.0.0.1:10808 -4 "$url" (10808端口是 xxx中默认的socks5转发端口 )

关于git http https 设置

配置git http https

sudo git config --global http.proxy socks5://127.0.0.1:10808
sudo git config --global https.proxy socks5://127.0.0.1:10808

取消git http https

sudo git config --global --unset http.proxy
sudo git config --global --unset https.proxy

编译完成后的输出说明

(1)static 编译输出目录为:

/root/ffmpeg-windows-build-helpers/sandbox/win64/ffmpeg_git

(2)shared编译输出目录为

/root/ffmpeg-windows-build-helpers/sandbox/win64/ffmpeg_git_master_shared

另外还会生成redist压缩包,路径为

/root/ffmpeg-windows-build-helpers/sandbox/redist

对于无法直接在ubuntu访问git的情况处理

可以下载压缩包按照脚本设置的文件夹名称,解压到

/root/ffmpeg-windows-build-helpers/sandbox/win64

例如 libwebp 解压目录名为 libwebp_git

对于已安装高版本的python3 或者meson仍然提示版本低问题

我是通过设置 update-alternatives ,将高版本优先设高一点

update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 2
update-alternatives --config python3

当前使用python3.8
meson如果已经安装了仍然提示版本不对可以通过 同样的方法去安装

meson 安装命令

pip3 install --user  meson

下载已经编译好的ffmpeg(shared + static)

FFMpeg4.4_windows_x86_64.zip

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值