From 248d8e09a9384fb4dafc599f58d98300023a0ade Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Tue, 27 Aug 2024 09:46:53 +0530 Subject: [PATCH] [desktop] Create ffmpeg universal binaries for macOS Tested locally, still need to run it as a GitHub action to verify that it is working as intended. Refs: - https://www.npmjs.com/package/ffmpeg-static#electron--other-cross-platform-packaging-tools - https://github.com/eugeneware/ffmpeg-static/issues/35 - https://github.com/eugeneware/ffmpeg-static/issues/136 --- desktop/.github/workflows/desktop-release.yml | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/desktop/.github/workflows/desktop-release.yml b/desktop/.github/workflows/desktop-release.yml index c8fccdaf7f5..02ab7c7e651 100644 --- a/desktop/.github/workflows/desktop-release.yml +++ b/desktop/.github/workflows/desktop-release.yml @@ -60,6 +60,31 @@ jobs: - name: Install dependencies run: yarn install + - name: Create universal ffmpeg binaries for macOS + if: startsWith(matrix.os, 'ubuntu') + # Currently, the ffmpeg-static binaries are not universal (Not + # their fault, we thank them for their useful package, the issue + # is that there don't seem to be well known upstream sources that + # provide a universal binary). + # + # As a workaround, we invoke ffmpeg-static twice to download both + # the Intel and ARM binaries, and combine them into a single + # universal binary using lipo. + # + # Note that the yarn install will run again, as part of the + # "build:ci" step, so we're relying on ffmpeg-static install.js's + # behaviour of not overwriting the existing file named `ffmpeg`. + run: | + rm -f node_modules/ffmpeg-static/ffmpeg + npm rebuild --arch=arm64 -f ffmpeg-static + mv node_modules/ffmpeg-static/ffmpeg node_modules/ffmpeg-static/ffmpeg-arm64 + npm rebuild --arch=x64 -f ffmpeg-static + mv node_modules/ffmpeg-static/ffmpeg node_modules/ffmpeg-static/ffmpeg-x64 + cd node_modules/ffmpeg-static/ + lipo -create ffmpeg-arm64 ffmpeg-x64 -output ffmpeg + rm ffmpeg-arm64 ffmpeg-x64 + file ffmpeg # print what we ended up with + - name: Install libarchive-tools for pacman build if: startsWith(matrix.os, 'ubuntu') # See: