Run FFmpeg from Node.js with an API
Send the FFmpeg command you already run in a terminal to Rendobar's FFmpeg API with @rendobar/sdk. The job runs on Rendobar's machines, so your server needs no ffmpeg binary, and rb.jobs.wait hands back the finished job with its output URL. The program below is complete: it sends the job, waits, stops on a failure and saves the file.
- Guide
- FFmpeg API
- Updated
- November 2026
import { createWriteStream } from "node:fs";import { Readable } from "node:stream";import { pipeline } from "node:stream/promises";import { createClient } from "@rendobar/sdk";
const rb = createClient({ apiKey: process.env.RENDOBAR_API_KEY });
const job = await rb.jobs.create({ type: "ffmpeg", inputs: { "source.mp4": "https://example.com/video.mp4" }, params: { command: "ffmpeg -i source.mp4 -vf scale=1280:-2 -c:v libx264 -crf 23 -c:a aac out.mp4", },});
// Polls until the job completes, fails or is cancelled.const done = await rb.jobs.wait(job.id);
if (done.status === "failed") { const { code, message, detail } = done.error; throw new Error(`${code}: ${message}\n${detail ?? ""}`);}if (done.status !== "complete") throw new Error(`Job ${done.id} was ${done.status}`);
// The output URL needs no key. Stream it to disk.const res = await fetch(done.output.file.url);if (!res.ok) throw new Error(`Download failed: ${res.status}`);await pipeline(Readable.fromWeb(res.body), createWriteStream("out.mp4"));How
How it works
Install the SDK and set your key
Create an API key in the dashboard under Settings, API keys, and put it in RENDOBAR_API_KEY. @rendobar/sdk ships ESM and CommonJS with full types, and the program at the top of this page runs as it is with node.
terminal npm install @rendobar/sdkexport RENDOBAR_API_KEY="YOUR_API_KEY"node transcode.mjsSend the command
rb.jobs.create takes the job type, your FFmpeg command and an inputs map. Each key is a name the command reads with -i and each value is the URL Rendobar downloads it from. It returns as soon as the job is saved. Any command from the recipes runs the same way.
What rb.jobs.create returns - id
- job_8f2c41d07a6e4b19
- type
- ffmpeg
- status
- waiting
Wait for it and read the result
rb.jobs.wait polls until the job completes, fails or is cancelled, and returns it. With no timeout given it waits as long as the job's own time limit. Narrow on status: output exists only on complete and error only on failed, so TypeScript stops you reading the wrong one. error.detail is the tail of FFmpeg's own stderr.
What rb.jobs.wait returns - status
- complete
- output.file.url
- https://…/out.mp4
- output.file.path
- out.mp4
- output.expiresAt
- Unix ms the link stops working
Send a local file
A job reads its inputs from URLs, so a file on disk goes up first. rb.uploads.create sends it straight to storage, in parallel parts when it is large, and returns the asset. Its url goes into inputs like any other URL. An upload is kept for 24 hours.
upload.mjs import { openAsBlob } from "node:fs";import { createClient } from "@rendobar/sdk";const rb = createClient({ apiKey: process.env.RENDOBAR_API_KEY });// Reads the file from disk as it uploads. Large files go up in parallel parts.const asset = await rb.uploads.create(await openAsBlob("clip.mov"), { filename: "clip.mov" });const job = await rb.jobs.create({type: "ffmpeg",inputs: { "clip.mov": asset.url },params: { command: "ffmpeg -i clip.mov -c:v libx264 -crf 23 -c:a aac out.mp4" },});Take a webhook instead of waiting
Register an endpoint in the dashboard under Webhooks and Rendobar POSTs job.completed or job.failed to it when a job ends. verifyWebhook checks the signature, rejects stale deliveries and keeps verifying while you rotate the secret. Pass it the raw body, never parsed JSON. The webhooks guide lists every event.
server.mjs (Express) import express from "express";import { verifyWebhook } from "@rendobar/sdk/webhooks";const app = express();// Keep the body as raw text. The signature covers the exact bytes.app.post("/rendobar-webhook", express.text({ type: "application/json" }), async (req, res) => {if (!(await verifyWebhook(req.body, req.headers, process.env.RENDOBAR_WEBHOOK_SECRET))) {return res.status(401).send("Bad signature");}const { event, data } = JSON.parse(req.body);// saveVideo and logFailure are your own code.if (event === "job.completed") await saveVideo(data.jobId, data.output.file.url);if (event === "job.failed") await logFailure(data.jobId, data.error);res.send("ok");});app.listen(3000);The same job with fetch
The SDK wraps two REST calls, so the global fetch in Node 18 and later runs the same job with no package. POST /jobs sends it and GET /jobs/{id} reads it until the status is final. The response wraps the job in data. The same two calls are how you call the FFmpeg API from Python with requests.
transcode-fetch.mjs import { setTimeout as sleep } from "node:timers/promises";const API = "https://api.rendobar.com";const headers = {Authorization: `Bearer ${process.env.RENDOBAR_API_KEY}`,"Content-Type": "application/json",};async function call(path, init = {}) {const res = await fetch(`${API}${path}`, { ...init, headers });if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);return (await res.json()).data;}const { id } = await call("/jobs", {method: "POST",body: JSON.stringify({type: "ffmpeg",inputs: { "source.mp4": "https://example.com/video.mp4" },params: { command: "ffmpeg -i source.mp4 -vf scale=1280:-2 -c:v libx264 -crf 23 -c:a aac out.mp4" },}),});let job = await call(`/jobs/${id}`);while (["waiting", "dispatched", "running"].includes(job.status)) {await sleep(2000);job = await call(`/jobs/${id}`);}console.log(job.status === "complete" ? job.output.file.url : job.error ?? job.status);Or from a shell with curl
The same two calls, for a quick check from a terminal or a CI step. The key goes in the Authorization header as a bearer token.
terminal curl https://api.rendobar.com/jobs \-H "Authorization: Bearer $RENDOBAR_API_KEY" \-H "Content-Type: application/json" \-d '{"type": "ffmpeg","inputs": { "source.mp4": "https://example.com/video.mp4" },"params": { "command": "ffmpeg -i source.mp4 -vf scale=1280:-2 -c:v libx264 -crf 23 -c:a aac out.mp4" }}'# {"data":{"id":"job_8f2c41d07a6e4b19","status":"waiting"}}curl https://api.rendobar.com/jobs/job_8f2c41d07a6e4b19 \-H "Authorization: Bearer $RENDOBAR_API_KEY"
FAQ
Frequently asked questions
Does the SDK work with TypeScript, Bun and Deno?
Yes. @rendobar/sdk needs Node 18 or later and runs in any runtime with fetch, Bun and Deno included. It ships ESM and CommonJS builds with full types, retries 429 and 5xx responses, and takes an AbortSignal on every method. The SDK reference covers every call.
Why does spawn('ffmpeg') fail with ENOENT?
The machine running Node has no ffmpeg binary on its PATH, which is common on serverless hosts and slim containers. A job sent to Rendobar's FFmpeg API needs no binary on your side. The same command runs on Rendobar's machines and Node only makes HTTP requests.
What does rb.jobs.wait do when a job fails?
It returns the job with status failed and its error, so your code decides what happens next. Pass throwOnFailure: true and it throws JobFailedError instead. A request the API refuses, such as a bad command or an empty balance, throws an ApiError from rb.jobs.create with a code like VALIDATION_ERROR or INSUFFICIENT_CREDITS.
Which FFmpeg flags work in the command?
The flags you use locally for codecs, filters, stream maps and formats. A command that writes several files returns each one in output.files. Options that read other files from disk, fetch over the network or run outside code fail with VALIDATION_ERROR before the job runs, and a filter that reads a file by name, such as subtitles=, needs that file passed in inputs.
What are the file size and run time limits?
An input can be up to 500 MB on Free and 10 GB on Pro and Studio. A job runs for up to 1 hour on Free and 9 hours on Pro and Studio, and params.timeout, in seconds, stops one sooner. Finished files are kept for 7 days on Free, 30 on Pro and 90 on Studio.
Can a Node app encode video on a GPU?
Put an NVENC encoder such as h264_nvenc in the command and the job runs on an NVIDIA L4, L40S or RTX PRO 6000, on Pro and Studio. Your Node process stays on whatever machine it is on. Only the job moves.
What does it cost?
Jobs are billed per second of compute. A VP9 transcode we measured used 2.2 cores for 6.1 seconds and cost $0.0071. Every account starts with $5 of free credit and no card, and Rendobar bills nothing while you're not running jobs. Plans are on the pricing page.
Your command. Our infrastructure.
Bring your own commands. Run them on scalable CPU and GPU infrastructure, and pay only for compute time.
