Version-specific Electron/Chromium patches for enabling additional media codec support, including:
- HEVC / H.265
- AC3
- E-AC3
- AC4
- DTS
- Dolby Vision-related platform flags
These patches are intended for building custom Electron binaries.
Caution
These patches only modify source/build behavior. They do not grant any codec, patent, distribution, or platform licenses. Make sure you understand the legal/licensing requirements before distributing binaries with proprietary codec support.
- v42.4.0
- v36.2.1+
Source: Electron GN build instructions
Install:
- Git
- Python 3
- Node.js
- Yarn/Corepack
depot_tools- Ninja / autoninja
- A C/C++ toolchain for your platform
Install depot_tools separately, outside the Chromium checkout:
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git depot_toolsAdd it to your PATH.
On macOS/Linux:
export PATH="$PWD/depot_tools:$PATH"On Windows cmd:
set PATH=C:\src\electron\depot_tools;%PATH%Important
On Windows, use a standalone depot_tools checkout. Do not rely on src\third_party\depot_tools as your user-facing depot_tools install. The vendored checkout can be incomplete for command-line use.
Install:
- Visual Studio 2022 Build Tools
- Desktop development with C++
- Windows 10/11 SDK
- Debugging Tools for Windows
The Debugging Tools are required because Chromium expects:
C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\dbghelp.dll
Set:
set DEPOT_TOOLS_WIN_TOOLCHAIN=0This tells Chromium/depot_tools to use your locally installed Visual Studio instead of trying to use Google’s internal toolchain.
If Python resolves to the Microsoft Store alias, disable:
Settings -> Apps -> Advanced app settings -> App execution aliases
Turn off:
python.exe
python3.exe
From the Chromium source root after sync:
cd /home/$USER/src/electron/src
sudo ./build/install-build-deps.sh --no-promptIf using @electron/build-tools, install Node through a version manager such as nvm. Do not install @electron/build-tools with sudo.
Example checkout path:
~/src/electron
On Windows, use something short like:
C:\src\electron
Run from the directory where you want the checkout:
mkdir -p ~/src/electron
cd ~/src/electron
gclient config --name "src/electron" --unmanaged https://github.com/electron/electron
gclient sync --with_branch_heads --with_tagsRun from cmd or x64 Native Tools Command Prompt:
mkdir C:\src\electron
cd /d C:\src\electron
gclient config --name "src/electron" --unmanaged https://github.com/electron/electron
gclient sync --with_branch_heads --with_tagsThis will take a while.
Run from:
<checkout>/src/electron
Example for v42.4.0:
cd src/electron
git fetch origin --tags
git checkout v42.4.0
git describe --tags --exact-matchExpected output:
v42.4.0
Then re-sync dependencies for that tag.
Run from:
<checkout>
cd ../..
gclient sync --with_branch_heads --with_tags -fImportant
Do not apply patches to main unless the patches were made for main. Most patch failures happen because the Electron tag does not match the patch version.
Copy the patch files into:
<checkout>/patches
Example:
~/src/electron/patches
or on Windows:
C:\src\electron\patches
Run from the Chromium source root:
<checkout>/src
cd ~/src/electron/src
for p in ../patches/electron-v42.4.0-*.patch; do
echo "Checking $p"
git apply --check "$p" || exit 1
done
for p in ../patches/electron-v42.4.0-*.patch; do
echo "Applying $p"
git apply "$p" || exit 1
doneRun from:
C:\src\electron\src
cd /d C:\src\electron\src
for %p in (..\patches\electron-v42.4.0-*.patch) do git apply --check "%p"
for %p in (..\patches\electron-v42.4.0-*.patch) do git apply "%p"If running inside a .bat file, use %%p instead of %p.
Verify:
git status --short
git diff --checkgit diff --check should ideally print nothing.
From:
<checkout>/src
for p in ../patches/electron-v42.4.0-*.patch; do
echo ""
echo "Patch: $p"
if git apply --reverse --check "$p" >/dev/null 2>&1; then
echo "already applied"
elif git apply --check "$p" >/dev/null 2>&1; then
echo "not applied"
else
echo "not cleanly applicable; possibly partially applied or wrong Electron version"
fi
doneThese builds require proprietary codec flags.
Base args:
import("//electron/build/args/release.gn")
target_cpu="x64"
proprietary_codecs=true
ffmpeg_branding="Chrome"
enable_platform_ac3_eac3_audio=true
enable_platform_ac4_audio=true
enable_platform_dts_audio=true
enable_platform_dolby_vision=true
enable_platform_hevc=true
enable_hevc_parser_and_hw_decoder=true
use_remoteexec=false
use_reclient=false
use_siso=falseFor v42.4.0, adding this may be necessary to avoid version detection failures during generated TypeScript/API steps:
override_electron_version="42.4.0"If a GN arg is unknown for your target Electron/Chromium version, remove that arg or update the patch set for that version.
Run from:
<checkout>/src
gn gen out/Release-x64 --args='import("//electron/build/args/release.gn") target_cpu="x64" proprietary_codecs=true ffmpeg_branding="Chrome" enable_platform_ac3_eac3_audio=true enable_platform_ac4_audio=true enable_platform_dts_audio=true enable_platform_dolby_vision=true enable_platform_hevc=true enable_hevc_parser_and_hw_decoder=true use_remoteexec=false use_reclient=false use_siso=false override_electron_version="42.4.0"'For Linux, you can use a Linux-specific output directory:
gn gen out/Release-linux-x64 --args='import("//electron/build/args/release.gn") target_os="linux" target_cpu="x64" proprietary_codecs=true ffmpeg_branding="Chrome" enable_platform_ac3_eac3_audio=true enable_platform_ac4_audio=true enable_platform_dts_audio=true enable_platform_dolby_vision=true enable_platform_hevc=true enable_hevc_parser_and_hw_decoder=true use_remoteexec=false use_reclient=false use_siso=false override_electron_version="42.4.0"'Run from:
C:\src\electron\src
gn gen out\Release-win-x64 --args="import(\"//electron/build/args/release.gn\") target_os=\"win\" target_cpu=\"x64\" proprietary_codecs=true ffmpeg_branding=\"Chrome\" enable_platform_ac3_eac3_audio=true enable_platform_ac4_audio=true enable_platform_dts_audio=true enable_platform_dolby_vision=true enable_platform_hevc=true enable_hevc_parser_and_hw_decoder=true use_remoteexec=false use_reclient=false use_siso=false override_electron_version=\"42.4.0\""If gn is not found on Windows, make sure standalone depot_tools is first in PATH.
Build ffmpeg before the full Electron target. This catches codec patch issues early.
Run from:
<checkout>/src
autoninja -C out/Release-linux-x64 third_party/ffmpeg:ffmpegor, if you used out/Release-x64:
autoninja -C out/Release-x64 third_party/ffmpeg:ffmpegRun from:
C:\src\electron\src
autoninja -C out\Release-win-x64 third_party/ffmpeg:ffmpegIf autoninja is unavailable, use ninja directly:
ninja -C out/Release-linux-x64 third_party/ffmpeg:ffmpegRun from:
<checkout>/src
autoninja -C out/Release-linux-x64 electron electron:electron_dist_zipor:
autoninja -C out/Release-x64 electron electron:electron_dist_zipRun from:
C:\src\electron\src
autoninja -C out\Release-win-x64 electron electron:electron_dist_zipThe final link step can take a long time, especially on Windows. It may appear quiet while linking electron.exe and generating .pdb files.
The distributable zip is produced by:
electron:electron_dist_zip
Search for artifacts:
find out -maxdepth 3 -name "*.zip" -o -name "dist*"dir out\Release-win-x64\*.zip
dir out\Release-win-x64\dist*On Linux, if needed, strip debug/symbol information before packaging:
cd <checkout>/src
electron/script/strip-binaries.py -d out/Release-linux-x64Then build the dist zip:
autoninja -C out/Release-linux-x64 electron:electron_dist_zipMost common causes:
- Wrong Electron tag
gclient syncwas not rerun after checking out the tag- Patch set is incomplete
- Patch was already partially applied
Check:
cd <checkout>/src/electron
git describe --tags --exact-matchThen rerun from:
<checkout>
gclient sync --with_branch_heads --with_tags -fYou are trying to use remote build settings. Disable them:
use_remoteexec=false
use_reclient=false
use_siso=falseIf using @electron/build-tools, also set:
"remoteBuild": "none"You are probably using vendored depot_tools from:
src\third_party\depot_tools
Use a standalone depot_tools checkout instead:
C:\src\electron\depot_tools
and put it first in PATH.
Install Debugging Tools for Windows through the Windows SDK installer.
Verify:
dir "C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\dbghelp.dll"Add:
override_electron_version="42.4.0"to your GN args.
Also verify:
cd /d C:\src\electron\src\electron
git describe --tags --exact-matchYou probably built only:
electronBuild the dist target too:
autoninja -C out/Release-linux-x64 electron:electron_dist_zipor build both at once:
autoninja -C out/Release-linux-x64 electron electron:electron_dist_zip