Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
feat(export): detect ffmpeg's capabilities — binary path, encoder pick and LGPL gate
Etienne Lescot5589baf3cecd
diff --git a/electron/media/ffmpegCapabilities.test.ts b/electron/media/ffmpegCapabilities.test.tsnew file mode 100644index 000000000..2a706f283--- /dev/null+++ b/electron/media/ffmpegCapabilities.test.ts@@ -0,0 +1,329 @@+import { describe, expect, it } from "vitest";+import {+ candidateFfmpegPaths,+ FFMPEG_BINARY_NAME,+ isLgplBuild,+ parseAvailableEncoders,+ selectVideoEncoder,+} from "./ffmpegCapabilities";++// Realistic slice of `ffmpeg -encoders` output (truncated for the test):+// header, capability description, separator, then a mix of video / audio /+// subtitle / data encoders. The parser must return every real encoder name+// and nothing from the header / separator / description rows.+const REALISTIC_ENCODERS_OUTPUT = [+ "Encoders:",+ " V..... = Video",+ " A..... = Audio",+ " S..... = Subtitle",+ " D..... = Data",+ "------",+ " V..... h264_qsv H.264 / AVC (Intel Quick Sync Video acceleration) (codec h264)",+ " V....D h264_amf AMD AMF H.264 Encoder (codec h264)",+ " V....D h264_nvenc NVIDIA NVENC H.264 encoder (codec h264)",+ " V....D libx264 libx264 H.264 / AVC / MPEG-4 AVC (codec h264)",+ " A....D aac AAC (Advanced Audio Coding)",+ " D..... bintext Binary text",+ " S..... ass ASS (Advanced SSA Subtitle)",+ " V..... h264_videotoolbox VideoToolbox H.264 Encoder (codec h264)",+ " V....D h264_vaapi H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (codec h264) (deprecated)",+].join("\n");++describe("ffmpegCapabilities", () => {+ describe("parseAvailableEncoders", () => {+ it("parses every encoder from the realistic ffmpeg -encoders fixture", () => {+ const encoders = parseAvailableEncoders(REALISTIC_ENCODERS_OUTPUT);+ expect(encoders.has("h264_qsv")).toBe(true);+ expect(encoders.has("h264_amf")).toBe(true);+ expect(encoders.has("h264_nvenc")).toBe(true);+ expect(encoders.has("libx264")).toBe(true);+ expect(encoders.has("aac")).toBe(true);+ expect(encoders.has("ass")).toBe(true);+ expect(encoders.has("bintext")).toBe(true);+ expect(encoders.has("h264_videotoolbox")).toBe(true);+ expect(encoders.has("h264_vaapi")).toBe(true);+ });++ it("ignores header, separator and capability-description rows", () => {+ const encoders = parseAvailableEncoders(REALISTIC_ENCODERS_OUTPUT);+ // Header word itself must not be treated as an encoder.+ expect(encoders.has("Encoders")).toBe(false);+ // Second token of description lines is "=", never added.+ expect(encoders.has("=")).toBe(false);+ // Capability nouns at the end of description lines must not leak.+ expect(encoders.has("Video")).toBe(false);+ expect(encoders.has("Audio")).toBe(false);+ expect(encoders.has("Subtitle")).toBe(false);+ expect(encoders.has("Data")).toBe(false);+ // Exactly the 9 real encoders from the fixture, nothing else.+ expect(encoders.size).toBe(9);+ });++ it("returns an empty set for empty / no-encoder input", () => {+ expect(parseAvailableEncoders("").size).toBe(0);+ expect(parseAvailableEncoders("\n").size).toBe(0);+ expect(parseAvailableEncoders("Encoders:\n------").size).toBe(0);+ });++ it("tolerates leading whitespace and - in flag positions", () => {+ const stdout = [+ " V----D h264_nvenc something",+ "\tA....D aac\t\t\tAAC (Advanced Audio Coding)",+ " V....D libx264 libx264 (codec h264)",+ ].join("\n");+ const encoders = parseAvailableEncoders(stdout);+ expect(encoders.has("h264_nvenc")).toBe(true);+ expect(encoders.has("aac")).toBe(true);+ expect(encoders.has("libx264")).toBe(true);+ });++ it("accepts CRLF line endings", () => {+ const encoders = parseAvailableEncoders("V....D h264_nvenc\r\nA....D aac\r\n");+ expect(encoders.has("h264_nvenc")).toBe(true);+ expect(encoders.has("aac")).toBe(true);+ expect(encoders.size).toBe(2);+ });+ });++ describe("selectVideoEncoder", () => {+ it("win32 prefers nvenc over qsv over amf", () => {+ expect(selectVideoEncoder(new Set(["h264_nvenc", "h264_qsv", "h264_amf"]), "win32")).toBe(+ "h264_nvenc",+ );+ });++ it("win32 falls back to qsv when nvenc is missing", () => {+ expect(selectVideoEncoder(new Set(["h264_qsv", "h264_amf"]), "win32")).toBe("h264_qsv");+ });++ it("win32 falls back to amf when only amf is available", () => {+ expect(selectVideoEncoder(new Set(["h264_amf"]), "win32")).toBe("h264_amf");+ });++ it("win32 returns null when none of its candidates are available", () => {+ expect(selectVideoEncoder(new Set(["libx264", "aac"]), "win32")).toBeNull();+ });++ it("darwin selects h264_videotoolbox", () => {+ expect(selectVideoEncoder(new Set(["h264_videotoolbox"]), "darwin")).toBe(+ "h264_videotoolbox",+ );+ });++ it("darwin returns null when videotoolbox is missing", () => {+ expect(selectVideoEncoder(new Set(["libx264"]), "darwin")).toBeNull();+ });++ it("linux prefers nvenc over vaapi", () => {+ expect(selectVideoEncoder(new Set(["h264_nvenc", "h264_vaapi"]), "linux")).toBe("h264_nvenc");+ });++ it("linux falls back to vaapi when nvenc is missing", () => {+ expect(selectVideoEncoder(new Set(["h264_vaapi"]), "linux")).toBe("h264_vaapi");+ });++ it("linux returns null when neither candidate is available", () => {+ expect(selectVideoEncoder(new Set(["libx264"]), "linux")).toBeNull();+ });++ it("returns null on platforms we have no encoder preference for", () => {+ // Same set that would resolve on win32 should NOT resolve on freebsd.+ const available = new Set(["h264_nvenc", "h264_qsv", "h264_amf"]);+ expect(selectVideoEncoder(available, "freebsd")).toBeNull();+ expect(selectVideoEncoder(available, "openbsd")).toBeNull();+ expect(selectVideoEncoder(available, "aix")).toBeNull();+ });++ it("returns null on an empty availability set for every supported platform", () => {+ expect(selectVideoEncoder(new Set(), "win32")).toBeNull();+ expect(selectVideoEncoder(new Set(), "darwin")).toBeNull();+ expect(selectVideoEncoder(new Set(), "linux")).toBeNull();+ });+ });++ describe("isLgplBuild", () => {+ it("rejects a build configured with --enable-gpl", () => {+ const buildConf = "--prefix=/usr --enable-shared --enable-gpl --enable-version3";+ expect(isLgplBuild(buildConf)).toBe(false);+ });++ it("rejects a build configured with --enable-nonfree", () => {+ const buildConf = "--prefix=/usr --enable-shared --enable-nonfree";+ expect(isLgplBuild(buildConf)).toBe(false);+ });++ it("accepts a clean LGPL build (no gpl or nonfree)", () => {+ const buildConf = "--prefix=/usr --enable-shared --enable-version3 --enable-libvpx";+ expect(isLgplBuild(buildConf)).toBe(true);+ });++ it("does not match --enable-gpl as a substring of another flag", () => {+ // gpl-something is a different flag entirely - not the one we care about.+ expect(isLgplBuild("--enable-gpl-something")).toBe(true);+ expect(isLgplBuild("--enable-nonfree-extra")).toBe(true);+ });++ it("accepts the ffmpeg banner `configuration:` line for a clean build", () => {+ const banner = "configuration: --prefix=/usr --enable-shared --enable-version3";+ expect(isLgplBuild(banner)).toBe(true);+ });++ it("rejects the ffmpeg banner `configuration:` line when --enable-gpl is present", () => {+ const banner = "configuration: --prefix=/usr --enable-gpl --enable-version3 --enable-libx264";+ expect(isLgplBuild(banner)).toBe(false);+ });++ it("rejects the ffmpeg banner `configuration:` line when --enable-nonfree is present", () => {+ const banner = "configuration: --enable-shared --enable-nonfree --enable-libfdk-aac";+ expect(isLgplBuild(banner)).toBe(false);+ });++ it("returns true for an empty / whitespace-only build configuration", () => {+ expect(isLgplBuild("")).toBe(true);+ expect(isLgplBuild(" ")).toBe(true);+ });+ });++ describe("candidateFfmpegPaths", () => {+ it("prepends the env override when set", () => {+ const paths = candidateFfmpegPaths({+ here: "/fake/repo",+ platform: "linux",+ arch: "x64",+ envOverride: "/custom/ffmpeg",+ });+ expect(paths[0]).toBe("/custom/ffmpeg");+ expect(paths).toContain("/fake/repo/electron/native/bin/linux-x64/ffmpeg");+ });++ it("emits ffmpeg.exe under <platform>-<arch> on win32", () => {+ const paths = candidateFfmpegPaths({+ here: "C:/fake/repo",+ platform: "win32",+ arch: "x64",+ });+ const resolved = paths.map((p) => p.replace(/\\/g, "/"));+ expect(resolved).toContain("C:/fake/repo/electron/native/bin/win32-x64/ffmpeg.exe");+ expect(resolved).toContain("C:/fake/repo/electron/native/bin/ffmpeg.exe");+ });++ it("emits bare ffmpeg on linux (no .exe anywhere)", () => {+ const paths = candidateFfmpegPaths({+ here: "/fake/repo",+ platform: "linux",+ arch: "x64",+ });+ expect(paths).toContain("/fake/repo/electron/native/bin/linux-x64/ffmpeg");+ expect(paths).toContain("/fake/repo/electron/native/bin/ffmpeg");+ expect(paths.every((p) => !p.endsWith(".exe"))).toBe(true);+ });++ it("emits bare ffmpeg on darwin (no .exe anywhere)", () => {+ const paths = candidateFfmpegPaths({+ here: "/fake/repo",+ platform: "darwin",+ arch: "arm64",+ });+ expect(paths).toContain("/fake/repo/electron/native/bin/darwin-arm64/ffmpeg");+ expect(paths.every((p) => !p.endsWith(".exe"))).toBe(true);+ });++ it("orders candidates: env > appPath > resourcesPath > here-tagged > here-bare", () => {+ const paths = candidateFfmpegPaths({+ here: "/fake/repo",+ platform: "linux",+ arch: "x64",+ appPath: "/app",+ resourcesPath: "/res",+ envOverride: "/env",+ });+ // Priority 1: env override comes first.+ expect(paths[0]).toBe("/env");+ // Priority 2: appPath-tagged candidate is present.+ expect(paths).toContain("/app/electron/native/bin/linux-x64/ffmpeg");+ // Priority 3: resourcesPath-tagged candidate is present.+ expect(paths).toContain("/res/electron/native/bin/linux-x64/ffmpeg");+ // Priority 4: here-tagged candidate is present.+ expect(paths).toContain("/fake/repo/electron/native/bin/linux-x64/ffmpeg");+ // Priority 5: cross-arch fallthrough with no platform tag is present.+ expect(paths).toContain("/fake/repo/electron/native/bin/ffmpeg");++ // Order is consistent across the layered candidates.+ const envIdx = paths.indexOf("/env");+ const appIdx = paths.indexOf("/app/electron/native/bin/linux-x64/ffmpeg");+ const resIdx = paths.indexOf("/res/electron/native/bin/linux-x64/ffmpeg");+ const hereIdx = paths.indexOf("/fake/repo/electron/native/bin/linux-x64/ffmpeg");+ const bareIdx = paths.indexOf("/fake/repo/electron/native/bin/ffmpeg");+ expect(envIdx).toBeLessThan(appIdx);+ expect(appIdx).toBeLessThan(resIdx);+ expect(resIdx).toBeLessThan(hereIdx);+ expect(hereIdx).toBeLessThan(bareIdx);+ });++ it("omits appPath / resourcesPath candidates when those inputs are null", () => {+ const paths = candidateFfmpegPaths({+ here: "/fake/repo",+ platform: "linux",+ arch: "x64",+ appPath: null,+ resourcesPath: null,+ });+ expect(paths.some((p) => p.startsWith("/app/"))).toBe(false);+ expect(paths.some((p) => p.startsWith("/res/"))).toBe(false);+ expect(paths).toContain("/fake/repo/electron/native/bin/linux-x64/ffmpeg");+ expect(paths).toContain("/fake/repo/electron/native/bin/ffmpeg");+ });++ it("skips platform-tagged candidates when platform or arch is missing", () => {+ const paths = candidateFfmpegPaths({ here: "/fake/repo" });+ // Only the cross-arch fallthrough is emitted without a platform tag.+ expect(paths).toEqual(["/fake/repo/electron/native/bin/ffmpeg"]);+ });+ });++ describe("FFMPEG_BINARY_NAME", () => {+ it("returns ffmpeg.exe on win32", () => {+ expect(FFMPEG_BINARY_NAME("win32")).toBe("ffmpeg.exe");+ });++ it("returns bare ffmpeg on every other platform", () => {+ expect(FFMPEG_BINARY_NAME("linux")).toBe("ffmpeg");+ expect(FFMPEG_BINARY_NAME("darwin")).toBe("ffmpeg");+ expect(FFMPEG_BINARY_NAME("freebsd")).toBe("ffmpeg");+ });+ });+});++// Added after research surfaced the real GPL/nonfree surface (ffmpeg.org/legal.html):+// checking --enable-gpl alone is not the whole gate.+describe("isLgplBuild — GPL externals and nonfree traps", () => {+ it("rejects each GPL-only external library", () => {+ for (const lib of [+ "libx264",+ "libx265",+ "libxvid",+ "libvidstab",+ "librubberband",+ "frei0r",+ "avisynth",+ ]) {+ expect(isLgplBuild(`--prefix=/x --enable-${lib} --enable-shared`)).toBe(false);+ }+ });++ it("rejects libfdk-aac — nonfree makes the binary unredistributable, and we encode AAC", () => {+ expect(isLgplBuild("--prefix=/x --enable-libfdk-aac")).toBe(false);+ });++ it("accepts a hardware-only LGPL build with the native aac encoder", () => {+ expect(+ isLgplBuild(+ "--prefix=/x --enable-shared --enable-amf --enable-nvenc --enable-libsvtav1 --enable-videotoolbox",+ ),+ ).toBe(true);+ });++ it("does not false-positive on a lib whose name merely contains a GPL one", () => {+ expect(isLgplBuild("--enable-libx264-shim-not-real")).toBe(true);+ });+});diff --git a/electron/media/ffmpegCapabilities.ts b/electron/media/ffmpegCapabilities.tsnew file mode 100644index 000000000..fee41b29a--- /dev/null+++ b/electron/media/ffmpegCapabilities.ts@@ -0,0 +1,237 @@+/**+ * Join path segments with forward slashes. Electron's docs and Node's+ * own internals both accept forward slashes on every platform, and using+ * `node:path`'s `path.join` on Windows would silently rewrite the+ * forward-slashed inputs the tests pass into backslashes - breaking the+ * pure-function contract where identical inputs produce identical outputs+ * regardless of host OS.+ */+function joinPosix(...segments: string[]): string {+ return segments.filter((s) => s.length > 0).join("/");+}++/**+ * Resolves the bundled ffmpeg binary for the export path's hardware-accelerated+ * encoder. The actual subprocess, muxing and bitstream handling live in a+ * separate module; this file only does pure capability detection so the+ * streaming layer can stay focused on I/O and the tests can run without ever+ * spawning a process.+ *+ * The resolution pattern mirrors electron/stt/gpuDetector.ts: a single+ * per-platform binary name (Win32 needs the .exe suffix so the OS image+ * loader can resolve it) and a layered set of candidate paths so the same+ * code works in npm run dev, the electron-builder staging tree and the+ * packaged installer.+ */++/** ffmpeg encoders we know how to drive, best-first per platform. */+export type VideoEncoderId =+ | "h264_nvenc"+ | "h264_qsv"+ | "h264_amf"+ | "h264_videotoolbox"+ | "h264_vaapi";++/**+ * Conventional binary name. Win32's loader requires the .exe suffix; on+ * every other platform ffmpeg is just ffmpeg. The argument exists so tests+ * can drive the function without mutating process.platform.+ */+export const FFMPEG_BINARY_NAME: (platform: NodeJS.Platform) => string = (platform) =>+ platform === "win32" ? "ffmpeg.exe" : "ffmpeg";++/**+ * Best hardware encoder per platform, in preference order. First match in+ * available wins; anything missing falls through to the next candidate,+ * and a platform with no entries returns null so the caller keeps the+ * existing WebCodecs encoder.+ *+ * Windows prefers NVIDIA, then Intel, then AMD: NVENC is the strongest and+ * most predictable of the three, QSV next, AMF last. AMF being last is about+ * throughput headroom, not quality — measured output was frame-identical to+ * software on the reference machine. Even AMF on an integrated Radeon+ * measured ~165 fps at 1080p versus ~8 fps for WebCodecs, so last place here+ * is still ~20x what we ship today.+ *+ * On Linux there is no QSV/AMF path worth having, so the realistic options+ * are NVENC (proprietary driver) and VAAPI.+ */+const ENCODER_PREFERENCE: Partial<Record<NodeJS.Platform, readonly VideoEncoderId[]>> = {+ win32: ["h264_nvenc", "h264_qsv", "h264_amf"],+ darwin: ["h264_videotoolbox"],+ linux: ["h264_nvenc", "h264_vaapi"],+};++/** Match ffmpeg -encoders flag columns: 6 capability characters from+ * V/A/S/D plus . (unset) and - (also unset on some builds). The flag+ * prefix is followed by whitespace, then the encoder name. */+const ENCODER_FLAG_PATTERN = /^[-VASD.]{6}$/;++/** Encoder names are always identifier-shaped; rejects description lines like+ * "V..... = Video" whose second token is "=". */+const ENCODER_NAME_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/;++/**+ * Where to look for the bundled ffmpeg, in priority order:+ * 1. OPENSCREEN_FFMPEG_EXE env override (debug builds)+ * 2. <appPath>/electron/native/bin/<platform>-<arch>/<name> (dev npm run+ * dev and electron-builder --dir unpacked staging)+ * 3. <resourcesPath>/electron/native/bin/<platform>-<arch>/<name>+ * (packaged installer - NSIS / dmg / AppImage put natives under+ * resources/)+ * 4. here/electron/native/bin/<platform>-<arch>/<name> (older checkout+ * shape + bare-bones tests)+ * 5. here/electron/native/bin/<name> (cross-arch fallthrough - same name,+ * no platform tag, lets a single checked-in binary serve every host)+ *+ * ponytail: on Windows we accept both ffmpeg.exe and bare ffmpeg as+ * candidate names so a checkout that pre-dates the suffix fix still resolves+ * to a valid file.+ *+ * Everything is read through the options bag so this function stays pure -+ * the streaming layer injects appPath / resourcesPath from the Electron+ * context, and tests pass literals.+ */+export function candidateFfmpegPaths(+ opts: {+ here?: string;+ platform?: NodeJS.Platform;+ arch?: string;+ appPath?: string | null;+ resourcesPath?: string | null;+ envOverride?: string | null;+ } = {},+): string[] {+ const here = opts.here ?? process.cwd();+ const platform = opts.platform;+ const arch = opts.arch;+ const appPath = opts.appPath ?? null;+ const resourcesPath = opts.resourcesPath ?? null;+ const envOverride = opts.envOverride ?? null;++ const tag = platform && arch ? `${platform}-${arch}` : null;+ const primary = platform ? FFMPEG_BINARY_NAME(platform) : "ffmpeg";+ const names = platform === "win32" ? [primary, "ffmpeg"] : [primary];++ const appPathSegments =+ appPath && tag ? names.map((n) => joinPosix(appPath, "electron", "native", "bin", tag, n)) : [];+ const resourceSegments =+ resourcesPath && tag+ ? names.map((n) => joinPosix(resourcesPath, "electron", "native", "bin", tag, n))+ : [];+ const hereSegments = tag+ ? names.map((n) => joinPosix(here, "electron", "native", "bin", tag, n))+ : [];++ return [+ ...(envOverride ? [envOverride] : []),+ ...appPathSegments,+ ...resourceSegments,+ ...hereSegments,+ // Cross-arch fallthrough: bare name with no platform tag - covers the+ // case where a dev checked in a single ffmpeg for their host only.+ ...names.map((n) => joinPosix(here, "electron", "native", "bin", n)),+ ];+}++/**+ * Parse ffmpeg -encoders stdout into the set of available encoder names.+ * Returns every encoder (video, audio, subtitle, data) - the caller filters+ * down to the VideoEncoderIds it cares about, so a future codec like+ * hevc_nvenc doesn't require touching this parser.+ *+ * Tolerant of leading whitespace (real ffmpeg output is sometimes+ * space-padded under the banner) and of - in flag positions (some builds+ * render -- instead of .. for unset capabilities).+ */+export function parseAvailableEncoders(stdout: string): Set<string> {+ const available = new Set<string>();+ for (const rawLine of stdout.split(/\r?\n/)) {+ const line = rawLine.trim();+ if (line.length === 0) continue;+ const tokens = line.split(/\s+/);+ if (tokens.length < 2) continue;+ if (!ENCODER_FLAG_PATTERN.test(tokens[0])) continue;+ if (!ENCODER_NAME_PATTERN.test(tokens[1])) continue;+ available.add(tokens[1]);+ }+ return available;+}++/**+ * Best hardware encoder for platform given the set of encoders ffmpeg+ * reported. Returns null when no candidate for that platform is present —+ * the caller keeps WebCodecs rather than reaching for a software encoder.+ * That is a licensing call, not a speed one: libx264 is actually the fastest+ * thing we measured (201 fps), but it is GPL and would relicense the binary+ * (see isLgplBuild). WebCodecs is slow but already shipped and MIT-clean.+ */+export function selectVideoEncoder(+ available: ReadonlySet<string>,+ platform: NodeJS.Platform,+): VideoEncoderId | null {+ const order = ENCODER_PREFERENCE[platform];+ if (!order) return null;+ for (const id of order) {+ if (available.has(id)) return id;+ }+ return null;+}++/**+ * External libraries ffmpeg documents as GPL-only. Enabling any one of them+ * relicenses the WHOLE binary to GPL, which would contaminate this MIT app.+ * Belt-and-braces: `--enable-gpl` is *required* to build these, so checking+ * the flag alone should suffice — but a third-party build could be patched,+ * and this is the list that actually decides the licence, so assert on it too.+ * Source: ffmpeg.org/legal.html.+ */+const GPL_EXTERNAL_LIBS = [+ "libx264",+ "libx265",+ "libxvid",+ "libxavs",+ "libxavs2",+ "libdavs2",+ "libvidstab",+ "librubberband",+ "libcdio",+ "frei0r",+ "avisynth",+] as const;++/**+ * Libraries that make the binary *unredistributable* — worse than GPL, since+ * no licence lets us ship the result at all. `libfdk-aac` is the trap here:+ * it is the AAC encoder everyone reaches for, and we encode AAC. Use ffmpeg's+ * native `aac` encoder instead. Source: ffmpeg.org/legal.html.+ */+const NONFREE_LIBS = ["libfdk-aac", "libfdk_aac", "openssl"] as const;++/**+ * True iff the ffmpeg build has NO GPL and NO nonfree component.+ *+ * ffmpeg is LGPL **by default** — there is no `--disable-gpl`; GPL only+ * appears if someone passes `--enable-gpl` (pulling x264/x265/…) or+ * `--enable-nonfree` (fdk-aac, OpenSSL-combined builds). It is all-or-nothing:+ * one GPL component relicenses the entire binary.+ *+ * This exists so CI can fail a build that would relicense the app — the whole+ * reason we build/ship ffmpeg ourselves is that we control these flags.+ *+ * Feed it `ffmpeg -buildconf` output, or the banner's `configuration:` line.+ */+export function isLgplBuild(buildConf: string): boolean {+ // Token-bounded so `--enable-gpl` matches but `--enable-gpl-something` does+ // not. The banner's `configuration:` line and a raw `-buildconf` dump are+ // both space-separated flags.+ if (/(?:^|\s)--enable-(?:gpl|nonfree)(?=\s|$)/.test(buildConf)) return false;++ for (const lib of [...GPL_EXTERNAL_LIBS, ...NONFREE_LIBS]) {+ // Matches --enable-libx264 and the bare token some -buildconf dumps use.+ if (new RegExp(String.raw`(?:^|\s)(?:--enable-)?${lib}(?=\s|$)`).test(buildConf)) {+ return false;+ }+ }+ return true;+}