Part of Hosting by frameworkHosting · Troubleshooting

“spawn ffmpeg ENOENT” and “Cannot find ffmpeg”: the binary isn’t on the server.

spawn ffmpeg ENOENT means Node asked the operating system to run ffmpeg and found no such file on the PATH; fluent-ffmpeg reports it as Cannot find ffmpeg. fluent-ffmpeg only wraps the binary, and Vercel, Netlify, Lambda and most native runtimes don’t include one. Ship it with ffmpeg-static, install it in a Dockerfile or buildpack, or call a media service.

Facts checked

The exact errors

Node prints the first one when child_process.spawn() can’t find the program; the process never starts, so there is no ffmpeg output to read. fluent-ffmpeg checks the FFMPEG_PATH variable, then searches the PATH, and gives up with the second. The third is the same Node error with a full path: something computed where the binary should be, and nothing is there.

# Node.js, when child_process can't find the binary (here on Linux)
Error: spawn ffmpeg ENOENT
  code: 'ENOENT',
  syscall: 'spawn ffmpeg',
  path: 'ffmpeg',

# fluent-ffmpeg, when FFMPEG_PATH and the PATH lookup both come up empty
Cannot find ffmpeg
Cannot find ffprobe          # from .ffprobe()

# A path that was computed but points at nothing (ffmpeg-static after a bundler rewrote it)
Error: spawn /ROOT/node_modules/ffmpeg-static/ffmpeg ENOENT

Why ffmpeg is missing

ffmpeg is a separate program, not an npm package. fluent-ffmpeg, pydub, Whisper and most media libraries build a command line and run it, so they need the binary on the machine where the code runs. Your laptop has it because you installed it; the server doesn’t.

CauseHow to tellFix
The host has no ffmpeg on the PATH (serverless functions, most buildpack runtimes) † †Cannot find ffmpeg, or spawn ffmpeg ENOENT with a bare ffmpegShip the binary (ffmpeg-static) or install it in the image (below)
ffmpeg-static’s install script never ran, so the binary wasn’t downloaded † †The path in the error ends in node_modules/ffmpeg-static/ffmpeg and the file isn’t thereAllow its install script; don’t install with --ignore-scripts
pnpm blocked the install script †pnpm lists ffmpeg-static among ignored buildsAdd allowBuilds: { ffmpeg-static: true } to pnpm-workspace.yaml (pnpm 10 called it onlyBuiltDependencies)
A bundler rewrote the package’s __dirname †The path starts with /ROOT/, /var/task/.next/ or similarKeep the package external (Next.js below)
setFfmpegPath() points at a path that doesn’t exist on Linux †spawn /usr/local/bin/ffmpeg ENOENT or a Windows pathUse the path ffmpeg-static returns, or FFMPEG_PATH set per environment

† Competitor details come from each vendor’s own published pages on the dates shown; prices and plans change, so check the vendor before you decide. The host has no ffmpeg on the PATH (serverless functions, most buildpack runtimes) (2026-11-25) · The host has no ffmpeg on the PATH (serverless functions, most buildpack runtimes) (2026-11-25) · ffmpeg-static’s install script never ran, so the binary wasn’t downloaded (2026-11-25) · ffmpeg-static’s install script never ran, so the binary wasn’t downloaded (2026-11-25) · pnpm blocked the install script (2026-11-25) · A bundler rewrote the package’s `__dirname` (2026-11-25) · `setFfmpegPath()` points at a path that doesn’t exist on Linux (2026-11-25)

Ship the binary with ffmpeg-static

ffmpeg-static downloads a static ffmpeg build for the platform it is installed on (ffmpeg 6.1.1 in version 5.3.0) and exports its absolute path. Because the download happens in its install script, the install has to run on Linux, on the server or in CI, not on your Mac with the result copied over. Calling the binary yourself is a few lines:

// npm install ffmpeg-static
import { spawn } from "node:child_process";
import ffmpegPath from "ffmpeg-static"; // absolute path to the binary, or null on an unsupported platform

export function ffmpeg(args) {
  return new Promise((resolve, reject) => {
    if (!ffmpegPath) return reject(new Error("ffmpeg-static has no binary for this platform"));
    const child = spawn(ffmpegPath, ["-hide_banner", "-y", ...args]);
    let stderr = "";
    child.stderr.on("data", (d) => (stderr += d));
    child.on("error", reject); // ENOENT lands here
    child.on("close", (code) =>
      code === 0 ? resolve() : reject(new Error(`ffmpeg exited ${code}: ${stderr.slice(-500)}`)));
  });
}

await ffmpeg(["-i", "in.mp4", "-vf", "scale=-2:240", "-c:a", "aac", "out_240.mp4"]);
await ffmpeg(["-ss", "1", "-i", "in.mp4", "-frames:v", "1", "thumb.jpg"]);

fluent-ffmpeg: set the path, and know it is deprecated

fluent-ffmpeg never bundled ffmpeg. Give it the binary once with setFfmpegPath() (and setFfprobePath() if you call .ffprobe(); ffmpeg-static has no ffprobe, the ffprobe-static package does).

The project itself is archived. Its README now opens with “Fluent-ffmpeg is now deprecated” and says it “no longer works properly with recent ffmpeg versions”, and npm marks 2.1.3 as deprecated. Existing code keeps working with the path set; for new code, spawning ffmpeg directly as above avoids the dependency.

// Existing fluent-ffmpeg code: point it at the binary once, at startup
import ffmpeg from "fluent-ffmpeg";
import ffmpegPath from "ffmpeg-static";

ffmpeg.setFfmpegPath(ffmpegPath);

ffmpeg("in.mp4")
  .noVideo()
  .audioCodec("libmp3lame")
  .audioBitrate(128)
  .on("error", (err) => console.error("ffmpeg failed:", err.message))
  .on("end", () => console.log("done"))
  .save("out.mp3");

// Python: imageio-ffmpeg ships the binary inside its wheel
//   import subprocess, imageio_ffmpeg
//   subprocess.run([imageio_ffmpeg.get_ffmpeg_exe(), "-y", "-i", "in.mp4", "out.mp3"], check=True)

Vercel and Next.js: bundling and file tracing

On Vercel the usual failure is not the download but the bundler. ffmpeg-static builds its path from __dirname, and when Next.js bundles the package into a route, that becomes a placeholder. We reproduced it with Next.js 16.2.4: the build passed and the route failed with Error: spawn \ROOT\...\node_modules\ffmpeg-static\ffmpeg.exe ENOENT (on Linux, /ROOT/node_modules/ffmpeg-static/ffmpeg). Adding the package to serverExternalPackages fixed it, and file tracing still copied the binary into the function. If a deployment ever ships without the binary, add it with outputFileTracingIncludes.

Then the limits. The Linux binary is about 80 MB uncompressed, and a Vercel function may be 250 MB uncompressed in total. A function’s request body is capped at 4.5 MB, so upload videos to storage first and pass the function a key, not the file. Encoding stops at the function’s maximum duration (below).

// next.config.js: keep ffmpeg-static out of the server bundle
module.exports = {
  serverExternalPackages: ["ffmpeg-static"],

  // Only if the deployed function still lacks the binary:
  // outputFileTracingIncludes: {
  //   "/api/clip": ["./node_modules/ffmpeg-static/ffmpeg"],
  // },
};

Platform by platform

Platformffmpeg out of the boxWhat to doLimits that bite
Vercel Functions †Noffmpeg-static + serverExternalPackages250 MB function, 4.5 MB request body, 300 s by default (800 s maximum on Pro)
Netlify Functions †Noffmpeg-static, listed in external_node_modules if the bundler drops it60 s synchronous, 15 min for background functions, 6 MB buffered payload
AWS Lambda †Noffmpeg-static in the zip, a layer, or a container image250 MB unzipped with layers, 10 GB container image, 15 min timeout, /tmp 512 MB to 10 GB
Heroku † †NoHeroku’s Active Storage preview buildpack (ffmpeg 7.1.3 on heroku-24). The popular heroku-buildpack-ffmpeg-latest says it is no longer maintainedDyno memory; keep encodes out of the web request
Render native runtimes †Yes, listed among installed toolsNothing; use Docker if you need another versionInstance memory
Railway † †NoRAILPACK_DEPLOY_APT_PACKAGES=ffmpeg; on Nixpacks NIXPACKS_PKGS=ffmpegService memory
ffmpeg.wasm † †Runs in the browser@ffmpeg/ffmpeg, no binary to installNo Node.js since 0.12; about 25 times slower than native; 2 GB input

† Competitor details come from each vendor’s own published pages on the dates shown; prices and plans change, so check the vendor before you decide. Vercel Functions (2026-11-25) · Netlify Functions (2026-11-25) · AWS Lambda (2026-11-25) · Heroku (2026-11-25) · Heroku (2026-11-25) · Render native runtimes (2026-11-25) · Railway (2026-11-25) · Railway (2026-11-25) · ffmpeg.wasm (2026-11-25) · ffmpeg.wasm (2026-11-25)

Install it in the image: Dockerfile, Heroku, Railway

Wherever you control the image, the system package is the simplest fix: it lands on the PATH, so spawn("ffmpeg") and fluent-ffmpeg find it with no code change. Debian’s package also brings ffprobe.

# Dockerfile (Render, Fly, Railway, Cloud Run, your own server)
FROM node:22-bookworm-slim
RUN apt-get update \
 && apt-get install -y --no-install-recommends ffmpeg \
 && rm -rf /var/lib/apt/lists/*

# Heroku: the Heroku-maintained buildpack that puts ffmpeg on the PATH
heroku buildpacks:add -i 1 https://github.com/heroku/heroku-buildpack-activestorage-preview
git commit --allow-empty -m "rebuild with ffmpeg" && git push heroku main

# Railway (Railpack, the default builder): a service variable
RAILPACK_DEPLOY_APT_PACKAGES=ffmpeg

# Railway on Nixpacks (in maintenance mode)
NIXPACKS_PKGS=ffmpeg

ffmpeg.wasm: no binary, a large speed cost

ffmpeg.wasm compiles ffmpeg to WebAssembly, so nothing has to be installed on any server: the visitor’s browser does the work. Its own benchmark converts a WebM to MP4 in 5.2 s with native ffmpeg, 128.8 s with the single-thread build and 60.4 s with the multi-thread build. Input is capped at 2 GB, a WebAssembly limit.

Since 0.12 it no longer supports Node.js, so it isn’t a server-side fix. It suits short clips the user already has on their device, such as trimming a recording before upload.

Long jobs on serverless: timeouts and /tmp

  • A minute of video is not a minute of encoding. Transcoding speed depends on the codec, resolution and CPU; a function with one vCPU is slow at H.264, slower at VP9. Time a real file before picking a platform.
  • Timeouts. Vercel functions default to 300 s (800 s maximum on Pro and Enterprise). Netlify synchronous functions stop at 60 s and background functions at 15 minutes. Lambda allows up to 15 minutes. A job that may take longer belongs in a queue with a worker, not in a request (background jobs).
  • Disk. ffmpeg needs a seekable file for MP4 output (the index is written at the end), so you usually write to /tmp. Lambda’s /tmp is 512 MB by default, configurable up to 10 GB; input plus output must fit.
  • Memory and payloads. Don’t read a whole video into memory to pass it around. Stream it from storage to a file, process, stream the result back, and send the client a link.

Or skip the binary: the Canner media service

On Canner, a Live project can turn on Media processing (ffmpeg) in its Services tab and redeploy. The app gets CANNER_FFMPEG_SOCKET, a unix socket: send one JSON line naming a preset, then the file, and read one JSON line, then the result. Nothing to install, bundle or keep patched. This is the Node.js client from the docs; the Python version is there too:

import net from "node:net";

export function run(input, preset, params = {}) {
  return new Promise((resolve, reject) => {
    const socket = net.connect(process.env.CANNER_FFMPEG_SOCKET);
    const chunks = [];
    socket.on("data", (d) => chunks.push(d));
    socket.on("error", reject);
    socket.on("close", () => {
      const reply = Buffer.concat(chunks);
      const end = reply.indexOf(10); // the header line ends at the first newline
      if (end < 0) return reject(new Error("no reply"));
      const head = JSON.parse(reply.subarray(0, end).toString());
      if (!head.ok) return reject(new Error(`${head.code}: ${head.error}`));
      resolve({ ...head, data: reply.subarray(end + 1, end + 1 + head.size) });
    });
    socket.write(JSON.stringify({ preset, size: input.length, params }) + "\n");
    socket.end(input);
  });
}

// const { data } = await run(fs.readFileSync("clip.mov"), "mp4", { height: 720 });

Presets, job minutes and limits

PresetParameters (default)Output
mp4height 144–1080 (720), crf 18–35 (28)H.264 + AAC
webmheight 144–1080 (720), crf 20–45 (34)VP9 + Opus
mp3, m4akbps 48–320 (128)Audio
wavchannels 1–2 (1), rate 8000–48000 (16000)Audio, e.g. for speech-to-text
thumbnailat seconds (1), width 16–1920 (640), quality 2–31 (5)JPEG
gifat (0), seconds 0.5–15 (3), width 16–800 (480), fps 1–20 (12)GIF
infononeJSON: streams and duration

Limits and job minutes

  • Inputs: MP4/MOV, WebM/MKV, AVI, WAV, MP3, AAC, OGG, FLAC, FLV and MPEG-TS, recognized from the bytes, not the file name.
  • Limits: 500 MB in, 1 GB out, 15 minutes a job, one job at a time per project, 20 a minute.
  • Job minutes: 300 a month per organization, shared with document rendering and OCR. A job minute is a minute of ffmpeg running, not a minute of video. The Media add-on adds 600 a month for $9.
  • On Canner without the service, ffmpeg-static won’t get its binary: builds install with --ignore-scripts, and allowlisted install scripts re-run with no network access, so its download can’t happen.

When you need raw ffmpeg instead

  • Arguments the presets don’t cover: filters (watermarks, overlays, crops), concatenation, subtitles, HLS or DASH packaging, HEVC or AV1, output above 1080p.
  • Live or streaming work: RTMP ingest, restreaming, anything that runs longer than 15 minutes.
  • Several jobs at once from one project, or volume beyond the monthly job minutes.
  • Starter projects don’t have services; they are Live and above.
  • For those, run ffmpeg where you control the image (the Dockerfile above) or use a dedicated video API. The service is for the common conversions: a web-friendly MP4, an audio track, a thumbnail.

Questions

What does spawn ffmpeg ENOENT mean?

Node tried to start a program called ffmpeg and the operating system found no such file on the PATH (or at the path you gave). It is not an ffmpeg error; ffmpeg never started.

Does fluent-ffmpeg include ffmpeg?

No. It builds command lines for a binary you provide. Install ffmpeg on the machine, or install ffmpeg-static and call ffmpeg.setFfmpegPath() with its path. The library is now deprecated and archived.

Can I use ffmpeg on Vercel?

Yes, with ffmpeg-static and serverExternalPackages: ["ffmpeg-static"] in next.config.js. Keep inputs out of the request body (4.5 MB limit) and jobs inside the function’s maximum duration.

Why does it work locally but not after deploying?

Your machine has ffmpeg on its PATH, or ffmpeg-static downloaded a macOS or Windows binary into node_modules. The server needs its own Linux binary, installed there, not copied from your machine.

Is ffmpeg.wasm a replacement on the server?

No. It dropped Node.js support in 0.12 and runs many times slower than native ffmpeg. Use it in the browser for small files.

Convert media without shipping ffmpeg.

Live projects get media processing, document rendering, OCR, a virus scan and a cache as switches on the Services tab, on servers in Montréal.