Error: spawn ffmpeg ENOENT means Node.js found no program named ffmpeg on PATH. Install ffmpeg, spawn the binary from ffmpeg-static, or send the same args to ReelSDK, which runs ffmpeg 8.1 for $0.02 per compute minute.
Error: spawn ffmpeg ENOENT
We reproduced it on Node.js 22 with no ffmpeg installed: spawn() threw errno -2 and, with no error listener, the process exited with code 1. ReelSDK ran the same scale in about 14 seconds without a binary.
ErrorsUpdated
node:events:497
throw er; // Unhandled 'error' event
^
Error: spawn ffmpeg ENOENT
at ChildProcess._handle.onexit (node:internal/child_process:285:19)
at onErrorNT (node:internal/child_process:483:16)
at process.processTicksAndRejections (node:internal/process/task_queues:89:21)
Emitted 'error' event on ChildProcess instance at:
at ChildProcess._handle.onexit (node:internal/child_process:291:12)
at onErrorNT (node:internal/child_process:483:16)
at process.processTicksAndRejections (node:internal/process/task_queues:89:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn ffmpeg',
path: 'ffmpeg',
spawnargs: [ '-i', 'in.mp4', '-vf', 'scale=720:-2', 'out.mp4' ]
}
Node.js v22.23.2Source: Node.js child_process docs, checked November 2026.
Where it shows up
spawn() fails before ffmpeg starts
You call spawn("ffmpeg", args) on a machine where no ffmpeg program is on the PATH. We reproduced it on Node.js 22 with spawn("ffmpeg", ["-i", "in.mp4", "-vf", "scale=720:-2", "out.mp4"]) and no ffmpeg installed.
Node prints throw er; // Unhandled 'error' event, then Error: spawn ffmpeg ENOENT and Emitted 'error' event on ChildProcess instance, then the error object with errno: -2, code: 'ENOENT', syscall: 'spawn ffmpeg', path: 'ffmpeg' and your spawnargs. The process exits with code 1.
Why it happens
ENOENT means the ffmpeg program was not found
In the Node.js error docs, ENOENT is "No such file or directory". The missing file is not your video: path: 'ffmpeg' and syscall: 'spawn ffmpeg' say it is the ffmpeg program itself.
Node looks the command up in options.env.PATH when you pass env, and in process.env.PATH otherwise. When no folder has it, the child process emits 'error'; with no listener attached, Node throws it and the process exits with code 1.
Causes and fixes
Where ffmpeg goes missing
| Where Node runs | Why ffmpeg is missing | Fix |
|---|---|---|
| Your laptop or a VM | ffmpeg was never installed, or its folder is not on PATH | Install it with your package manager, or spawn the ffmpeg-static path |
| A Docker image | The base image ships without ffmpeg | Install it in the Dockerfile, or use ffmpeg-static |
| Vercel, Netlify or AWS Lambda | The function runtime has no ffmpeg binary | Bundle ffmpeg-static within the size limit, or call an API |
| systemd, PM2 or a GUI launcher | Node can start with a different PATH than your shell | Spawn an absolute path, or set PATH for the service |
| spawn with a custom env | An env without PATH makes Node search /usr/bin:/bin only | Spread process.env into the env you pass |
Source: Node.js child_process docs, checked November 2026.
The local fix
Install ffmpeg, or ship it with your app
Install ffmpeg so it is on PATH, or add ffmpeg-static from npm and pass its path to spawn. It is GPL-3.0-or-later and gets nearly 4 million downloads a week; on Linux x64 it fetches an 80 MB binary of ffmpeg 7.0. With it, the same scale=720:-2 command ran with no ffmpeg on PATH and wrote a 720x1280 file.
Attach an 'error' listener either way. Your app then stays up and gets the error object with error.code set to "ENOENT". The 'close' event still fires afterwards, with code -2, so don't read that as an ffmpeg failure.
import { spawn } from "node:child_process";
import ffmpegPath from "ffmpeg-static";
const args = ["-y", "-i", "in.mp4", "-vf", "scale=720:-2", "out.mp4"];
const ffmpeg = spawn(ffmpegPath, args);
ffmpeg.on("error", (error) => {
console.error("ffmpeg failed to start:", error.message);
});
ffmpeg.on("close", (code) => console.log("ffmpeg exited with code", code));import { spawn } from "node:child_process";
const args = ["-y", "-i", "in.mp4", "-vf", "scale=720:-2", "out.mp4"];
const ffmpeg = spawn("/usr/bin/ffmpeg", args);
ffmpeg.on("error", (error) => {
console.error("ffmpeg failed to start:", error.message);
});
ffmpeg.on("close", (code) => console.log("ffmpeg exited with code", code));import { spawn } from "node:child_process";
const args = ["-y", "-i", "in.mp4", "-vf", "scale=720:-2", "out.mp4"];
const ffmpeg = spawn("ffmpeg", args);
ffmpeg.on("error", (error) => {
if (error.code === "ENOENT") {
console.error("ffmpeg not found on PATH:", process.env.PATH);
} else {
console.error("ffmpeg failed to start:", error.message);
}
});
ffmpeg.on("close", (code) => console.log("ffmpeg exited with code", code));Skip the binary
Or skip the binary: send the same args to the API
POST /v1/ffmpeg takes the same flags in args, your input URLs in inputs and the files to keep in outputs, and runs them on ffmpeg 8.1 on a fresh machine per job. There is no binary to install or bundle.
On a 28-second vertical video, the same scale=720:-2 command finished in about 14 seconds. Compute costs $0.02 per minute, billed per second with a 1-second minimum, so that job cost a fraction of a cent. Failed jobs are free, and new accounts get $0.50 of free credit.
const res = await fetch("https://api.reelsdk.com/v1/ffmpeg?wait=60", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.REELSDK_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({
"inputs": {
"in.mp4": "https://api.reelsdk.com/f/out/job_x5wepdaqkop4tepq05xp/video.mp4"
},
"args": [
"-i", "in.mp4", "-vf", "scale=720:-2", "-c:v", "libx264", "-crf", "23",
"-c:a", "aac", "-movflags", "+faststart", "out.mp4"
],
"outputs": ["out.mp4"]
}),
});
const { job } = await res.json();scale=720:-2 command on the API, scaled down to 720x1280.Input: 1080x1920 inputIt works in your terminal but not in Node
ffmpeg runs in your shell because its folder is on your shell's PATH. Node only sees the PATH it was started with: a service manager, a process manager or a desktop launcher can start it with a shorter one, and so can a container or a serverless runtime that never had ffmpeg.
If you pass options.env to spawn, Node uses that PATH instead. Leave PATH out of it and, per the child_process docs, the lookup on Unix falls back to /usr/bin:/bin. Spread process.env into the object you pass to keep the rest.
exec() fails differently
exec("ffmpeg ...") runs the command through /bin/sh, so you get no ENOENT at all. The callback gets an error with code 127, and stderr reads /bin/sh: 1: ffmpeg: not found. The fix is the same: put ffmpeg on PATH, use an absolute path, or skip the binary.
FAQ
Questions, answered
What does ENOENT mean?
ENOENT is the system error "No such file or directory". On spawn("ffmpeg", ...), the error object's path: 'ffmpeg' tells you the missing file is the ffmpeg program, not your input video.
Why does ffmpeg work in my terminal but not in Node?
Node searches the PATH it was started with, or the PATH in the env you pass to spawn. Services, process managers, desktop launchers, containers and serverless runtimes often have a different PATH or no ffmpeg at all. Spawn an absolute path or the ffmpeg-static path to rule it out.
Is ffmpeg-static a good fix on Vercel or AWS Lambda?
It can work: it adds an 80 MB Linux x64 binary of ffmpeg 7.0 to your deployment, so check your platform's function size limit first. Sending the same args to an API avoids the binary entirely.
How do I stop the error from crashing my app?
Attach an 'error' listener to the ChildProcess that spawn() returns. Node then hands the error to your handler instead of throwing it; check error.code for "ENOENT" and show a clear message. The close event still fires afterwards with code -2.
- FileNotFoundError: No such file or directory: 'ffmpeg'Python asked the OS for a program called ffmpeg and found none on its PATH. Install it, use imageio-ffmpeg, or call ffmpeg over HTTP.
- Error: Cannot find module '@ffmpeg/core'@ffmpeg/ffmpeg 0.11 loads its WebAssembly core from a package it does not install. Add @ffmpeg/core@0.11.0, or skip WebAssembly in Node.
- ffmpeg exited with code 1: Conversion failed!fluent-ffmpeg reports only ffmpeg's exit code and last line. The real cause is in stderr: print it, or use -v error to see it alone.
- Unknown encoder 'libx264'Your ffmpeg build has no x264 inside. Use libopenh264, install a GPL build, or send the same args to an API that has libx264.
- FUNCTION_INVOCATION_TIMEOUTVercel stopped the function at its max duration, 300 s on Hobby. Raise maxDuration, speed up ffmpeg, or return early with a webhook.
- Vercel FunctionsVercel Functions cap bodies at 4.5 MB and bundles at 250 MB. Upload to Vercel Blob, send the URL and your ffmpeg arguments to ReelSDK from a route handler, get an mp4 link back. $0.02 per compute minute.
- AWS LambdaAWS Lambda caps a function and its layers at 250 MB unzipped and runs for 900 s at most. Send your ffmpeg arguments to ReelSDK from a Node handler and get the files back by webhook. $0.02 per compute minute.
- ReelSDK vs fluent-ffmpegfluent-ffmpeg was archived in May 2025 but still gets 3.6 million downloads a week. ReelSDK runs the same ffmpeg arguments on ffmpeg 8.1: a 720p transcode plus thumbnail for about a fifth of a cent.
- ReelSDK vs self-hosted FFmpegTranscoding a minute of 1080p to 720p takes about 24 seconds of compute: about 0.8 cents on ReelSDK, about a tenth of a cent on a busy 4 vCPU box. Below about 11,000 minutes a month, the API costs less than an always-on box.
- Resize a video with ffmpegScale a video with scale=w:h: keep the aspect ratio with -2, fit a 1080x1920 frame with pad, and fix the odd-size error.
Sources, checked November 2026
Ready to build?
Ship video from your app today
Your first $0.50 is free, and one key covers every endpoint.
