Skip to content

The swiss army knife of lossless video/audio editing

Fail the build if the bundled ffmpeg is missing

Claude21ecb54acbf6
diff --git a/README.md b/README.md
index 4cd235da..d0cc8e79 100644
--- a/README.md
+++ b/README.md
@@ -118,7 +118,7 @@ If you prefer to download the executables manually, this will of course always b
- macOS: [Intel](https://github.com/mifi/lossless-cut/releases/latest/download/LosslessCut-mac-x64.dmg) / [Apple Silicon](https://github.com/mifi/lossless-cut/releases/latest/download/LosslessCut-mac-arm64.dmg) DMG (note that PKG does **not** work)
- Windows: [7zip](https://github.com/mifi/lossless-cut/releases/latest/download/LosslessCut-win-x64.7z) (Windows 7, 8 and 8.1 is [no longer supported after v3.50.0](docs/requirements.md))
-- Linux: [x64 tar.bz2](https://github.com/mifi/lossless-cut/releases/latest/download/LosslessCut-linux-x64.tar.bz2) / [x64 AppImage](https://github.com/mifi/lossless-cut/releases/latest/download/LosslessCut-linux-x86_64.AppImage) / [arm64 tar.bz2](https://github.com/mifi/lossless-cut/releases/latest/download/LosslessCut-linux-arm64.tar.bz2) / [Raspberry Pi armv7l](https://github.com/mifi/lossless-cut/releases/latest/download/LosslessCut-linux-armv7l.tar.bz2)
+- Linux: [x64 tar.bz2](https://github.com/mifi/lossless-cut/releases/latest/download/LosslessCut-linux-x64.tar.bz2) / [x64 AppImage](https://github.com/mifi/lossless-cut/releases/latest/download/LosslessCut-linux-x86_64.AppImage) / [arm64 tar.bz2](https://github.com/mifi/lossless-cut/releases/latest/download/LosslessCut-linux-arm64.tar.bz2) / [Raspberry Pi armv7l](https://github.com/mifi/lossless-cut/releases/latest/download/LosslessCut-linux-armv7l.tar.bz2) (the arm64 and armv7l builds don't include FFmpeg: install it yourself and select its directory in Settings → Custom FFmpeg directory, with advanced settings enabled)
- [More releases](https://github.com/mifi/lossless-cut/releases) - Note that APPX (Windows) and PKG (macOS) do **not** work)
- [Latest nightly builds 🧪](https://mifi.no/llc/nightly/)
diff --git a/package.json b/package.json
index 28e1592b..e3c1ff88 100644
--- a/package.json
+++ b/package.json
@@ -181,6 +181,7 @@
"onlyLoadAppFromAsar": true
},
"appId": "no.mifi.losslesscut",
+ "afterPack": "./script/afterPack.ts",
"artifactName": "${productName}-${os}-${arch}.${ext}",
"extraResources": [
{
diff --git a/script/afterPack.ts b/script/afterPack.ts
new file mode 100644
index 00000000..6eb6c149
--- /dev/null
+++ b/script/afterPack.ts
@@ -0,0 +1,18 @@
+// electron-builder afterPack hook: fail the build if the bundled ffmpeg/ffprobe are missing.
+// electron-builder only warns when an `extraResources` source doesn't exist, so a missing ffmpeg would otherwise ship silently.
+import assert from 'node:assert';
+import { existsSync } from 'node:fs';
+import { join } from 'node:path';
+import type { AfterPackContext } from 'electron-builder';
+import { Arch } from 'electron-builder';
+
+export default async function afterPack({ appOutDir, arch, electronPlatformName, packager }: AfterPackContext) {
+ // We have no ffmpeg builds for Linux ARM (see script/downloadFfmpeg.ts)
+ if (electronPlatformName === 'linux' && arch !== Arch.x64) return;
+
+ const resourcesDir = packager.getResourcesDir(appOutDir);
+ for (const name of ['ffmpeg', 'ffprobe']) {
+ const path = join(resourcesDir, electronPlatformName === 'win32' ? `${name}.exe` : name);
+ assert(existsSync(path), `${path} is missing. Did you run download-ffmpeg for ${electronPlatformName}-${Arch[arch]}?`);
+ }
+}