Skip to content

Commit 1dd26cc

Browse files
authored
feat: Adding new downloadAlternateFFmpeg option to download non-proprietary ffmpeg library (#7210) (#7477)
1 parent 12ac3cf commit 1dd26cc

File tree

8 files changed

+241
-6
lines changed

8 files changed

+241
-6
lines changed

.changeset/honest-mugs-invite.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"app-builder-lib": minor
3+
---
4+
5+
feat: Adding new `downloadAlternateFFmpeg` option to download non-proprietary ffmpeg library

docs/configuration/configuration.md

+3
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ Env file `electron-builder.env` in the current dir ([example](https://github.com
102102
<p><code id="Configuration-buildVersion">buildVersion</code> String | “undefined” - The build version. Maps to the <code>CFBundleVersion</code> on macOS, and <code>FileVersion</code> metadata property on Windows. Defaults to the <code>version</code>. If <code>buildVersion</code> is not defined and <code>buildNumber</code> (or one of the <code>buildNumber</code> envs) is defined, it will be used as a build version (<code>version.buildNumber</code>).</p>
103103
</li>
104104
<li>
105+
<p><code id="Configuration-downloadAlternateFFmpeg">downloadAlternateFFmpeg</code> Boolean - Whether to download the alternate FFmpeg library from Electron’s release assets and replace the default FFmpeg library prior to signing</p>
106+
</li>
107+
<li>
105108
<p><code id="Configuration-electronCompile">electronCompile</code> Boolean - Whether to use <a href="http://github.com/electron/electron-compile">electron-compile</a> to compile app. Defaults to <code>true</code> if <code>electron-compile</code> in the dependencies. And <code>false</code> if in the <code>devDependencies</code> or doesn’t specified.</p>
106109
</li>
107110
<li>

packages/app-builder-lib/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"chromium-pickle-js": "^0.2.0",
6262
"debug": "^4.3.4",
6363
"ejs": "^3.1.8",
64+
"electron-packager-plugin-non-proprietary-codecs-ffmpeg": "^1.0.2",
6465
"electron-publish": "workspace:*",
6566
"form-data": "^4.0.0",
6667
"fs-extra": "^10.1.0",

packages/app-builder-lib/scheme.json

+4
Original file line numberDiff line numberDiff line change
@@ -6666,6 +6666,10 @@
66666666
],
66676667
"description": "macOS DMG options."
66686668
},
6669+
"downloadAlternateFFmpeg": {
6670+
"description": "Whether to download the alternate FFmpeg library from Electron's release assets and replace the default FFmpeg library prior to signing",
6671+
"type": "boolean"
6672+
},
66696673
"electronBranding": {
66706674
"$ref": "#/definitions/ElectronBrandingOptions",
66716675
"description": "The branding used by Electron's distributables. This is needed if a fork has modified Electron's BRANDING.json file."

packages/app-builder-lib/src/configuration.ts

+5
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ export interface Configuration extends PlatformSpecificBuildOptions {
144144
*/
145145
readonly buildVersion?: string | null
146146

147+
/**
148+
* Whether to download the alternate FFmpeg library from Electron's release assets and replace the default FFmpeg library prior to signing
149+
*/
150+
readonly downloadAlternateFFmpeg?: boolean
151+
147152
/**
148153
* Whether to use [electron-compile](http://github.com/electron/electron-compile) to compile app. Defaults to `true` if `electron-compile` in the dependencies. And `false` if in the `devDependencies` or doesn't specified.
149154
*/

packages/app-builder-lib/src/electron/ElectronFramework.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { getTemplatePath } from "../util/pathManager"
1414
import { createMacApp } from "./electronMac"
1515
import { computeElectronVersion, getElectronVersionFromInstalled } from "./electronVersion"
1616
import * as fs from "fs/promises"
17+
import replaceFFMPEG from "electron-packager-plugin-non-proprietary-codecs-ffmpeg"
1718

1819
export type ElectronPlatformName = "darwin" | "linux" | "win32" | "mas"
1920

@@ -132,8 +133,12 @@ class ElectronFramework implements Framework {
132133
}
133134
}
134135

135-
prepareApplicationStageDirectory(options: PrepareApplicationStageDirectoryOptions) {
136-
return unpack(options, createDownloadOpts(options.packager.config, options.platformName, options.arch, this.version), this.distMacOsAppName)
136+
async prepareApplicationStageDirectory(options: PrepareApplicationStageDirectoryOptions) {
137+
await unpack(options, createDownloadOpts(options.packager.config, options.platformName, options.arch, this.version), this.distMacOsAppName)
138+
if (options.packager.config.downloadAlternateFFmpeg) {
139+
log.info(null, "downloading non-proprietary FFMPEG, piping output")
140+
await new Promise<void>(resolve => replaceFFMPEG(options.appOutDir, options.version, options.platformName, options.arch, resolve))
141+
}
137142
}
138143

139144
beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions) {

0 commit comments

Comments
 (0)