Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adding new downloadAlternateFFmpeg option to download non-proprietary ffmpeg library #7477

Merged
merged 1 commit into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/honest-mugs-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-builder-lib": minor
---

feat: Adding new `downloadAlternateFFmpeg` option to download non-proprietary ffmpeg library
3 changes: 3 additions & 0 deletions docs/configuration/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ Env file `electron-builder.env` in the current dir ([example](https://github.com
<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>
</li>
<li>
<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>
</li>
<li>
<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>
</li>
<li>
Expand Down
1 change: 1 addition & 0 deletions packages/app-builder-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"chromium-pickle-js": "^0.2.0",
"debug": "^4.3.4",
"ejs": "^3.1.8",
"electron-packager-plugin-non-proprietary-codecs-ffmpeg": "^1.0.2",
"electron-publish": "workspace:*",
"form-data": "^4.0.0",
"fs-extra": "^10.1.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/app-builder-lib/scheme.json
Original file line number Diff line number Diff line change
Expand Up @@ -6666,6 +6666,10 @@
],
"description": "macOS DMG options."
},
"downloadAlternateFFmpeg": {
"description": "Whether to download the alternate FFmpeg library from Electron's release assets and replace the default FFmpeg library prior to signing",
"type": "boolean"
},
"electronBranding": {
"$ref": "#/definitions/ElectronBrandingOptions",
"description": "The branding used by Electron's distributables. This is needed if a fork has modified Electron's BRANDING.json file."
Expand Down
5 changes: 5 additions & 0 deletions packages/app-builder-lib/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ export interface Configuration extends PlatformSpecificBuildOptions {
*/
readonly buildVersion?: string | null

/**
* Whether to download the alternate FFmpeg library from Electron's release assets and replace the default FFmpeg library prior to signing
*/
readonly downloadAlternateFFmpeg?: boolean

/**
* 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.
*/
Expand Down
9 changes: 7 additions & 2 deletions packages/app-builder-lib/src/electron/ElectronFramework.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { getTemplatePath } from "../util/pathManager"
import { createMacApp } from "./electronMac"
import { computeElectronVersion, getElectronVersionFromInstalled } from "./electronVersion"
import * as fs from "fs/promises"
import replaceFFMPEG from "electron-packager-plugin-non-proprietary-codecs-ffmpeg"

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

Expand Down Expand Up @@ -132,8 +133,12 @@ class ElectronFramework implements Framework {
}
}

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

beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions) {
Expand Down