·8 min read
Simple Video Compressor: an Electron app around FFmpeg and NVENC
I got tired of opening a command line every time a screen recording was too big to send. So I wrapped FFmpeg in a small Electron app: drop a video, move a quality slider, press compress. It looks like a thin shell, but a few details turned out to be interesting, and I want to write down the ones the code and the history actually show.
- Role
- Creator and sole developer
- Period
- Sep 2025 to Mar 2026
- Status
- Released v2.0.0 (1 Mar 2026), 1 star on GitHub
- Stack
- JavaScript, Electron, FFmpeg, ffprobe
The challenge
Video files are the thing people most often cannot attach: a screen recording of a few minutes can be hundreds of megabytes. FFmpeg solves this well, but its flags are not something you remember. -crf or -b:v, -preset, -vf scale=1280:-2, -movflags +faststart: each is one search away and all of them together are one mistake away from a bad file.
The app had three jobs. Hide the flags behind sensible controls. Use the GPU when it can. And show progress honestly, because a compression with no feedback looks identical to a hung program.
My responsibility
I wrote and released it alone. I owned:
- The Electron main process: FFmpeg spawning, ffprobe duration lookup, cancel and cleanup.
- The IPC surface between the window and the main process.
- The interface: a segmented control for encoder, GPU and quality method, sliders, language toggle (Georgian and English) and light and dark themes.
- Packaging with
electron-builder, including bundlingffmpeg.exeandffprobe.exenext to the app. - The two releases,
v1.0.0andv2.0.0.
How I approached it
Building the FFmpeg command
The main process assembles the argument list from the options it receives. Software encoding uses -crf. Hardware encoding uses -cq and, in bitrate mode, adds -maxrate at 1.1 times the target and -bufsize at twice the target:
if (isHardware) {
const hwPresets = ["default","slow","medium","fast","hp","hq","bd","ll","llhq","llhp","lossless"];
ffmpegArgs.push("-preset", hwPresets.includes(preset) ? preset : "default");
if (method === "CRF") ffmpegArgs.push("-cq", safeCRF);
else ffmpegArgs.push("-b:v", `${safeBitrate}k`, "-maxrate", `${Math.floor(safeBitrate * 1.1)}k`, "-bufsize", `${safeBitrate * 2}k`);
}Every output also gets -c:a aac at the chosen audio bitrate and -movflags +faststart, so the result starts playing before it finishes downloading. Output goes next to the source as compressed_<name>, and getAvailableFilename adds (1), (2) instead of overwriting.
- 01
Read the options
encoder, GPU type, CRF or bitrate, preset, resolution, fps, audio
- 02
Detect encoders
run ffmpeg -encoders and look for h264_nvenc, hevc_nvenc, h264_amf, hevc_amf
- 03
Choose the encoder
hardware if listed, otherwise libx264 or libx265
- 04
Probe the duration
ffprobe reads format=duration for the progress maths
- 05
Spawn and stream
parse time= and size= from stderr, reply with progress
Safety of the window
The window is created with contextIsolation: true and nodeIntegration: false, and preload.js exposes only the calls the UI needs: open dialog, resolve a dropped file's path, start and cancel compression, reveal a file, and four event subscriptions. The renderer cannot spawn processes on its own.
Story moments
Presets that mean different things
The first hardware commit (69ffe96, Nov 2025) added NVIDIA and AMD support, and with it a quiet trap. The preset dropdown offers ultrafast, fast, medium, slow and veryslow, which are x264 names. The hardware path has its own list of accepted names (the whitelist in main.js), and x264-only names like ultrafast are not on it. The guard is the whitelist above: if the chosen preset is not on it, use default. It overlaps on fast, medium and slow, so those pass through, while ultrafast and veryslow quietly become default.
It is a small guard, but it is the difference between an app that works on the developer's machine and one that works when someone changes a dropdown.
h264_nvenc on a PC without an NVIDIA GPU would fail with an error rather than fall back.A progress bar that tells the truth
In the first version the main process stat-ed the output file to report its size. In the redesign (b899b60, Mar 2026) I switched to the number FFmpeg already prints:
const timeMatch = msg.match(/time=(\d+):(\d+):(\d+\.\d+)/);
const sizeMatch = msg.match(/size=\s*(\d+)kB/);
...
if (sizeMatch) currentSize = parseInt(sizeMatch[1]) * 1024;
else currentSize = fs.statSync(outputPath).size; // fallbackThe percent comes from time= divided by the duration ffprobe reported, capped at 100. The remaining time is elapsed / currentTime * duration - elapsed. The renderer then turns that into an estimated final size with two methods, current size divided by percent, and bytes per second times the projected total time, blended 40/60:
estimated = estimated ? (estimated * 0.4 + byTime * 0.6) : byTime;A size estimate is only useful if it is not wildly wrong at 3 percent, which is why I kept a stat-based fallback when the regex finds nothing. I did not measure how accurate the estimate is across files, so I describe it as a design, not a result.
Drag and drop that the README promised
The README in the very first commit lists drag and drop. The renderer in that commit contains no drop handler at all (I searched it for drop, drag and .path). In v2 I added one, and it needed a detail that is easy to miss under context isolation: the renderer cannot read a dropped file's path directly. The preload script now imports webUtils from Electron and exposes it as a single function:
getPathForFile: (file) => webUtils.getPathForFile(file),The renderer checks the extension against .mp4, .mov, .mkv, .avi and .webm, calls that function and only then accepts the file. A leftover get-path-for-file handler in main.js still returns null with a comment calling it a fallback. It is dead code and I would delete it.
Project journey
Sep 2025
v1.0.0
first GitHub release, dated 4 Sep 2025
Nov 2025
69ffe96
NVIDIA and AMD encoder support, ffmpeg bundled, README added
Mar 2026
b899b60
redesign: 5 files, 1,126 insertions and 621 deletions
Mar 2026
v2.0.0
release tagged 1 Mar 2026, marked Latest
files changed in the redesign commit
lines added in b899b60
lines removed in b899b60
lines in main.js today
Beyond the launch
After v2 the app gained the things a utility needs to be pleasant: settings persisted in localStorage (encoder, GPU, method, CRF, bitrate, preset, resolution, fps and audio), a language switch between Georgian and English, a theme switch, toasts for errors and cancellation, a result card with the size reduction and a button that opens the folder in Explorer.
Things I know are unfinished. package.json still says version 1.0.0 although the release is v2.0.0, and the README is a short Georgian page that still says 1.0.0. The FFmpeg and ffprobe paths are relative (ffmpeg/ffmpeg.exe), so they depend on where the app is started. The first commit also added a 98,781,696 byte ffmpeg.exe to the repository, which is why a clone is heavy.
The outcome
What I can verify: a working Windows Electron app with two tagged releases, hardware encoder selection with a safe fallback, an interface in two languages and two themes, cancellation that deletes the partial output, and a repository with one star. I do not have download counts, benchmark numbers or user feedback to report, and I will not invent them.
For me it was a lesson in how much a good tool is the sum of small decisions: a preset whitelist, a fallback size source, and a preload bridge that exposes only what the window needs.
Try the app on one of your own recordings, or star the repo if a small FFmpeg front end is useful to you.
View on GitHubEvidence
- Repository: https://github.com/ddatunashvili/SIMPLE_VIDEO_COMPRESSOR, tags
v1.0.0(4 Sep 2025) andv2.0.0(1 Mar 2026). - Commits: 69ffe96 (1 Nov 2025) and b899b60 (1 Mar 2026).
- Files I relied on:
main.js,preload.js,renderer.js,index.html,package.json,README.md. - Not verified: I did not build or run the app for this article, did not test NVIDIA or AMD encoding on hardware, and have no measurements of compression ratio or estimate accuracy.
#electron#ffmpeg#javascript#desktop-app
Keep reading
Have a project in mind?