Adds a variants array to video upload collections and a Video processing panel in the admin where editors enqueue FFmpeg transcoding jobs from configured presets. Jobs run through a BullMQ queue on Redis and are handled by a separate worker CLI that either initializes Payload locally or falls back to REST. Requires Redis, a Payload 3 project, and a path field on the upload collection for local storage.
Queued FFmpeg video variant processing for Payload CMS
Installation
npm i @kimjansheden/payload-video-processor1
Stars
0
Forks
2
Open Issues
2 weeks ago
Last Updated
61
Weekly Downloads
v0.1.16
npm Version
1.2 MB
Unpacked Size
8
Dependencies
10 since Sep 6
| Date | Stars |
|---|---|
| Dec 5, 2026 | 1 |
| Dec 4, 2026 | 1 |
| Dec 3, 2026 | 1 |
| Dec 2, 2026 | 1 |
| Dec 1, 2026 | 1 |
| Nov 30, 2026 | 1 |
| Nov 29, 2026 | 1 |
| Nov 28, 2026 | 1 |
| Nov 27, 2026 | 1 |
| Nov 26, 2026 | 1 |
| Nov 25, 2026 | 1 |
| Nov 24, 2026 | 1 |
| Nov 23, 2026 | 1 |
| Nov 22, 2026 | 1 |
| Nov 21, 2026 | 1 |
| Nov 20, 2026 | 1 |
| Nov 19, 2026 | 1 |
| Nov 18, 2026 | 1 |
| Nov 17, 2026 | 1 |
| Nov 16, 2026 | 1 |
| Nov 15, 2026 | 1 |
| Nov 14, 2026 | 1 |
| Nov 13, 2026 | 1 |
| Nov 12, 2026 | 1 |
| Nov 11, 2026 | 1 |
| Nov 10, 2026 | 1 |
| Nov 9, 2026 | 1 |
| Nov 8, 2026 | 1 |
| Nov 7, 2026 | 1 |
| Nov 6, 2026 | 1 |
| Nov 5, 2026 | 1 |
| Nov 4, 2026 | 1 |
| Nov 3, 2026 | 1 |
| Nov 2, 2026 | 1 |
| Nov 1, 2026 | 1 |
| Oct 31, 2026 | 1 |
| Oct 30, 2026 | 1 |
| Oct 29, 2026 | 1 |
| Oct 28, 2026 | 1 |
| Oct 27, 2026 | 1 |
| Oct 26, 2026 | 1 |
| Oct 25, 2026 | 1 |
| Oct 24, 2026 | 1 |
| Oct 23, 2026 | 1 |
| Oct 22, 2026 | 1 |
| Oct 21, 2026 | 1 |
| Oct 20, 2026 | 1 |
| Oct 19, 2026 | 1 |
| Oct 18, 2026 | 1 |
| Oct 17, 2026 | 1 |
| Oct 16, 2026 | 1 |
| Oct 15, 2026 | 1 |
| Oct 14, 2026 | 1 |
| Oct 13, 2026 | 1 |
| Oct 12, 2026 | 1 |
| Oct 11, 2026 | 1 |
| Oct 10, 2026 | 1 |
| Oct 9, 2026 | 1 |
| Oct 8, 2026 | 1 |
| Oct 7, 2026 | 1 |
| Oct 6, 2026 | 1 |
| Oct 5, 2026 | 1 |
| Oct 4, 2026 | 1 |
| Oct 3, 2026 | 1 |
| Oct 2, 2026 | 1 |
| Oct 1, 2026 | 1 |
| Sep 30, 2026 | 1 |
| Sep 29, 2026 | 1 |
| Sep 28, 2026 | 1 |
| Sep 27, 2026 | 1 |
| Sep 26, 2026 | 1 |
| Sep 25, 2026 | 1 |
| Sep 24, 2026 | 1 |
| Sep 23, 2026 | 1 |
| Sep 22, 2026 | 1 |
| Sep 21, 2026 | 1 |
| Sep 20, 2026 | 1 |
| Sep 19, 2026 | 1 |
| Sep 18, 2026 | 1 |
| Sep 17, 2026 | 1 |
| Sep 16, 2026 | 1 |
| Sep 15, 2026 | 1 |
| Sep 14, 2026 | 1 |
| Sep 13, 2026 | 1 |
| Sep 12, 2026 | 1 |
| Sep 11, 2026 | 1 |
| Sep 10, 2026 | 1 |
| Sep 9, 2026 | 1 |
| Sep 8, 2026 | 1 |
| Sep 7, 2026 | 1 |
| Sep 6, 2026 | 1 |
30+22 since Sep 6
| Date | Weekly downloads |
|---|---|
| Dec 5, 2026 | 30 |
| Dec 4, 2026 | 30 |
| Dec 3, 2026 | 29 |
| Dec 2, 2026 | 29 |
| Dec 1, 2026 | 29 |
| Nov 30, 2026 | 28 |
| Nov 29, 2026 | 28 |
| Nov 28, 2026 | 29 |
| Nov 27, 2026 | 28 |
| Nov 26, 2026 | 27 |
| Nov 25, 2026 | 27 |
| Nov 24, 2026 | 11 |
| Nov 23, 2026 | 12 |
| Nov 22, 2026 | 14 |
| Nov 21, 2026 | 12 |
| Nov 20, 2026 | 13 |
| Nov 19, 2026 | 13 |
| Nov 18, 2026 | 39 |
| Nov 17, 2026 | 38 |
| Nov 16, 2026 | 37 |
| Nov 15, 2026 | 35 |
| Nov 14, 2026 | 37 |
| Nov 13, 2026 | 36 |
| Nov 12, 2026 | 36 |
| Nov 11, 2026 | 11 |
| Nov 10, 2026 | 27 |
| Nov 9, 2026 | 28 |
| Nov 8, 2026 | 28 |
| Nov 7, 2026 | 37 |
| Nov 6, 2026 | 37 |
| Nov 5, 2026 | 37 |
| Nov 4, 2026 | 37 |
| Nov 3, 2026 | 21 |
| Nov 2, 2026 | 20 |
| Nov 1, 2026 | 26 |
| Oct 31, 2026 | 14 |
| Oct 30, 2026 | 13 |
| Oct 29, 2026 | 11 |
| Oct 28, 2026 | 8 |
| Oct 27, 2026 | 9 |
| Oct 26, 2026 | 11 |
| Oct 25, 2026 | 4 |
| Oct 24, 2026 | 4 |
| Oct 23, 2026 | 4 |
| Oct 22, 2026 | 8 |
| Oct 21, 2026 | 17 |
| Oct 20, 2026 | 17 |
| Oct 19, 2026 | 15 |
| Oct 18, 2026 | 14 |
| Oct 17, 2026 | 15 |
| Oct 16, 2026 | 15 |
| Oct 15, 2026 | 11 |
| Oct 14, 2026 | 4 |
| Oct 13, 2026 | 3 |
| Oct 12, 2026 | 3 |
| Oct 11, 2026 | 4 |
| Oct 10, 2026 | 3 |
| Oct 9, 2026 | 3 |
| Oct 8, 2026 | 4 |
| Oct 7, 2026 | 4 |
| Oct 6, 2026 | 4 |
| Oct 5, 2026 | 4 |
| Oct 4, 2026 | 7 |
| Oct 3, 2026 | 7 |
| Oct 2, 2026 | 8 |
| Oct 1, 2026 | 7 |
| Sep 30, 2026 | 10 |
| Sep 29, 2026 | 10 |
| Sep 28, 2026 | 10 |
| Sep 27, 2026 | 6 |
| Sep 26, 2026 | 11 |
| Sep 25, 2026 | 10 |
| Sep 24, 2026 | 12 |
| Sep 23, 2026 | 17 |
| Sep 22, 2026 | 23 |
| Sep 21, 2026 | 39 |
| Sep 20, 2026 | 45 |
| Sep 19, 2026 | 43 |
| Sep 18, 2026 | 44 |
| Sep 17, 2026 | 44 |
| Sep 16, 2026 | 34 |
| Sep 15, 2026 | 29 |
| Sep 14, 2026 | 14 |
| Sep 13, 2026 | 8 |
| Sep 12, 2026 | 5 |
| Sep 11, 2026 | 4 |
| Sep 10, 2026 | 7 |
| Sep 9, 2026 | 8 |
| Sep 8, 2026 | 8 |
| Sep 7, 2026 | 7 |
| Sep 6, 2026 | 8 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1124768439-video-plugin)<a href="https://payloaddirectory.dev/plugins/1124768439-video-plugin"><img src="https://payloaddirectory.dev/badge/1124768439-video-plugin.svg" alt="Payload Directory"></a>README
Queued FFmpeg-based video variant generation for Payload CMS. The plugin mirrors
Payload's image size workflow for videos by adding a variants[] array to video
collections and exposing an Admin UI that lets editors enqueue transcoding jobs.
Designed to be plug-and-play: no custom endpoints, no extra UI code in the
consumer project.
react-easy-crop for frame-accurate crops.pnpm add @kimjansheden/payload-video-processor
Peer dependencies (payload, react, react-dom) must already exist in your
Payload project. The package bundles static FFmpeg/ffprobe binaries via
ffmpeg-static; if those are blocked on your platform, set FFMPEG_BIN to a
system ffmpeg binary (for example /opt/homebrew/bin/ffmpeg on macOS/Homebrew).
Define presets and register the plugin in your payload.config.ts (or wherever you build your Payload config):
import { buildConfig } from "payload";
import { mongooseAdapter } from "@payloadcms/db-mongodb";
import videoPlugin from "@kimjansheden/payload-video-processor";
const videoOptions = {
presets: {
mobile360: {
label: "360p Mobile",
args: ["-vf", "scale=-2:360", "-crf", "32"],
},
hd720: {
label: "720p HD",
args: ["-vf", "scale=-2:720", "-crf", "24"],
enableCrop: true,
},
},
queue: {
redisUrl: process.env.REDIS_URL,
concurrency: 1,
},
// Auto-enqueue a preset when a new video is uploaded.
autoEnqueue: true,
// Optional: override the default preset used on create.
autoEnqueuePreset: "hd720",
// Optional: replace the original with the auto-generated variant.
autoReplaceOriginal: true,
};
export default buildConfig({
// This plugin works with both DATABASE_URI and MONGODB_URI; the worker CLI maps DATABASE_URI -> MONGODB_URI.
db: mongooseAdapter({
url: process.env.DATABASE_URI ?? process.env.MONGODB_URI ?? "",
}),
collections: [
/* … */
],
plugins: [videoPlugin(videoOptions)],
});
Recommended host pattern: export the options object from src/videoPluginOptions.ts and import it in both your Payload config and worker/payload.worker.config.ts, so presets/queue settings stay in one place.
When autoEnqueue is true, the plugin
tries a preset named 1080, then hd1080, and finally falls back to the first
configured preset.
Set autoEnqueuePreset to force a specific preset name when auto-enqueueing.
Cropping is optional and configured per preset via enableCrop: true.
enableCrop only exposes crop controls in the Admin UI.import videoPlugin, {
type VideoPluginOptions,
} from "@kimjansheden/payload-video-processor";
const presets = {
mobile360: { label: "360p Mobile", args: ["-vf", "scale=-2:360"] },
hd1080: { label: "Full HD 1080p", args: ["-vf", "scale=-2:1080"] },
} satisfies VideoPluginOptions["presets"];
type PresetName = keyof typeof presets;
const options: VideoPluginOptions<PresetName> = {
presets,
queue: { redisUrl: process.env.REDIS_URL, concurrency: 1 },
autoEnqueue: true,
autoEnqueuePreset: "hd1080",
autoReplaceOriginal: true,
};
ESM:
import videoPlugin from "@kimjansheden/payload-video-processor";
CommonJS:
const videoPlugin = require("@kimjansheden/payload-video-processor").default;
For the worker options module, either export default (ESM) or use
module.exports = options (CommonJS), then point the CLI at the built file.
| Option | Type | Notes |
|---|---|---|
presets | Record<string, Preset> | Required. Keys become preset names. |
queue | QueueConfig | Optional queue name/redis URL/concurrency. |
autoEnqueue | boolean | true uses autoEnqueuePreset or the default fallback. |
autoEnqueuePreset | string | Must match a preset key, not the label. |
autoReplaceOriginal | boolean | Only applies to auto-enqueued jobs. |
access | AccessControl | Optional access control hooks. |
resolvePaths | (args) => ResolvePathsResult | Override output directory/filename/URL. |
path (local filesystem)The worker needs to read the original upload from disk. For local filesystem
storage, the worker reads the original file path from doc.path (absolute path
on disk). If your upload collection does not already provide a path, add a
read-only field and populate it from your upload staticDir + filename:
import path from "node:path";
import { fileURLToPath } from "node:url";
import type { CollectionConfig } from "payload";
const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename);
const staticDir =
process.env.STATIC_DIR ?? path.resolve(dirname, "../../public/media");
export const Media: CollectionConfig = {
slug: "media",
upload: {
staticDir,
mimeTypes: ["video/mp4", "video/webm", "video/quicktime"],
},
fields: [
{
name: "path",
type: "text",
admin: { readOnly: true, position: "sidebar" },
},
],
hooks: {
afterRead: [
({ doc }) => {
if (doc && typeof doc.filename === "string") {
doc.path = path.join(staticDir, doc.filename);
}
return doc;
},
],
},
};
Provide a worker options module and bundle it to JS (the CLI needs a JS file). Example:
// src/videoPluginOptions.ts
export default videoOptions;
tsup src/videoPluginOptions.ts --format esm --platform node --target es2022 --out-dir dist-config --minify
When you pass --payload-config, the worker can initialize Payload locally and update documents via the local Node API.
// worker/payload.worker.config.ts
import { mongooseAdapter } from "@payloadcms/db-mongodb";
import { buildConfig } from "payload";
import videoPlugin from "@kimjansheden/payload-video-processor";
import { Media } from "../src/collections/Media";
import videoPluginOptions from "../src/videoPluginOptions";
export default buildConfig({
telemetry: false,
secret: process.env.PAYLOAD_SECRET || "dev-secret",
db: mongooseAdapter({
url: process.env.MONGODB_URI || process.env.DATABASE_URI || "",
}),
plugins: [videoPlugin(videoPluginOptions)],
collections: [Media],
});
Bundle it:
tsup worker/payload.worker.config.ts --format esm --platform node --target es2022 --out-dir dist-config --minify
Start the worker in a separate process:
payload-video-worker \
--config ./dist-config/videoPluginOptions.js \
--payload-config ./dist-config/payload.worker.config.js
To initialize Payload locally, ensure PAYLOAD_SECRET + DATABASE_URI (or MONGODB_URI) are set. If you
prefer the REST fallback, omit --payload-config and provide
PAYLOAD_REST_URL + PAYLOAD_ADMIN_TOKEN.
The CLI loads .env, .env.local, .env.development, and .env.production
automatically (unless you pass --no-default-env). Additional --env flags can
point to project-specific files.
Example (explicit env + static dir, useful in monorepos):
FFMPEG_BIN=/opt/homebrew/bin/ffmpeg payload-video-worker \
--no-default-env \
--config ./dist-config/videoPluginOptions.js \
--payload-config ./dist-config/payload.worker.config.js \
--env .env \
--env .env.development \
--static-dir ./public/media
Prefer a fully programmatic setup? Import createWorker directly and pass the
same options object you provide to the plugin.
In the Admin UI a "Video processing" panel appears on any upload collection that accepts video/* mime types. Editors can enqueue presets, preview variants, replace the original file with a processed version, or delete unwanted variants without writing custom endpoints.
Most projects bundle both the plugin options and a minimal Payload config for the worker:
{
"scripts": {
"bundle:video-plugin-options": "tsup src/videoPluginOptions.ts --format esm --platform node --target es2022 --out-dir dist-config --minify",
"bundle:payload-worker-config": "tsup worker/payload.worker.config.ts --format esm --platform node --target es2022 --out-dir dist-config --minify",
"video:worker": "pnpm bundle:payload-worker-config && pnpm bundle:video-plugin-options && payload-video-worker --config ./dist-config/videoPluginOptions.js --payload-config ./dist-config/payload.worker.config.js",
"video:worker:dev": "pnpm bundle:payload-worker-config && pnpm bundle:video-plugin-options && FFMPEG_BIN=/opt/homebrew/bin/ffmpeg payload-video-worker --no-default-env --config ./dist-config/videoPluginOptions.js --payload-config ./dist-config/payload.worker.config.js --env .env --env .env.development --static-dir ./public/media",
},
}
This repository also includes apps/example-payload, a CLI-only reference
project that demonstrates plugin configuration + worker processing without
shipping a full /admin UI app. See apps/example-payload/README.md.
pnpm build – bundles ESM/CJS + admin assets via tsup.pnpm dev – watch mode build useful during plugin development.pnpm typecheck – tsc --noEmit for type validation.pnpm test – unit tests for helper utilities using Vitest.pnpm worker – development helper that runs the compiled worker entry.
(Application projects should prefer the payload-video-worker CLI.)| Variable | Purpose |
|---|---|
REDIS_URL | Default Redis connection string for queue + worker. |
FFMPEG_BIN | Optional path to a system ffmpeg binary (overrides ffmpeg-static). |
STATIC_DIR | Base media directory for the worker (used when resolving paths). |
PAYLOAD_SECRET / DATABASE_URI / MONGODB_URI | Required to bootstrap the Payload local API from the worker. |
PAYLOAD_REST_URL + PAYLOAD_ADMIN_TOKEN | REST fallback when local init is not possible. |
PAYLOAD_PUBLIC_URL / PAYLOAD_SERVER_URL | Alternative base URL for REST fallback if PAYLOAD_REST_URL is not set. |
PAYLOAD_CONFIG_PATH | Absolute/relative path to the host payload.config.ts for worker bootstrap. |
Provide a resolvePaths function to control where variants are written:
videoPlugin({
presets,
resolvePaths: ({ original, presetName }) => ({
dir: path.join("/data/videos", presetName),
filename: `${path.parse(original.filename).name}.${presetName}.mp4`,
url: `/videos/${presetName}/${path.parse(original.filename).name}.mp4`,
}),
});
The installed binary payload-video-worker bootstraps environment variables,
loads your exported plugin options, and starts the queue worker. It automatically
loads .env, .env.local, .env.development, and .env.production (unless you
pass --no-default-env). Supply --env to load additional files, --config to
point at the bundled options module, --payload-config when you want the worker
to initialise Payload locally, and --static-dir if your media folder is not
./public/media.
payload-video-worker \
--config ./dist-config/videoPluginOptions.js \
--payload-config ./dist-config/payload.worker.config.js \
--env .env \
--env cms/.env
The CLI sets common fallbacks (STATIC_DIR, PAYLOAD_CONFIG_PATH,
MONGODB_URI ← DATABASE_URI, default PAYLOAD_SECRET) before invoking
createWorker. It shuts down gracefully on SIGINT/SIGTERM.
Contributions are welcome. Please open an issue or PR with a clear description of the change and how to test it. If you add features, include a short README note so onboarding stays accurate.
plugin adaptive bitrate videos
Automatic HLS adaptive bitrate transcoding for video uploads in Payload collections
4827/wk22v3
payload video stream
Send video uploads from Payload upload collections to Cloudflare Stream and track processing status
5166/wk8v3
payload media
Search stock images and videos from Unsplash, Pexels, Pixabay and Openverse inside the Payload admin
83900/wk8v4
mux video
Upload and manage Mux videos from a dedicated Payload collection with public or signed playback
793.9k/wk84v3
payload plugin media preview
Preview images, video, audio, code, CSV and Office files in the Payload admin edit and list views
66632/wk14v4
payload video streaming
Video upload, encoding status and playback for Payload using Cloudflare Stream, Mux or Bunny Stream
65961/wk0v3 v4