BarakChamo

payload video streaming

by BarakChamo
Media & images
v3
v4
^3.94.0 || ^4.0.0-beta.12
MIT

Overview

Summary generated from the README

Adds a videos collection to Payload that uploads files directly from the browser to Cloudflare Stream, Mux or Bunny Stream. It provides admin tools for processing status, posters, captions and audio tracks, plus React components for rendering with the provider's player or your own. Requires Payload 3.94+ or 4 beta and an account with one of the providers.

Features

  • Direct browser uploads to the provider with resumable and multi-file support
  • Admin UI for processing status, posters, captions, audio tracks and downloads
  • videoField and videoBlock for collections, layout builders and Lexical rich text
  • React components with the provider's iframe player or a custom HLS player
  • Optional signed playback and access hooks for private videos
  • Webhooks, sync jobs and orphan cleanup for provider videos

Use cases

  • Embed hero videos in posts with hosted streaming instead of storing files on your server
  • Let site members upload videos with ownership and moderation before publishing
  • Serve private videos using signed playback tokens

From the author

Video streaming for Payload CMS (v3 and v4) with Cloudflare Stream, Mux and Bunny Stream: direct uploads, signed playback, webhooks, captions, blocks and bring-your-own player.

Installation

npm i payload-video-streaming

0

Stars

0

Forks

4

Open Issues

Today

Last Updated

961

Weekly Downloads

v0.6.1

npm Version

1.0 MB

Unpacked Size

2

Dependencies

GitHub stars

00 since Nov 29

Show data
GitHub stars by day (UTC)
DateStars
Dec 6, 20260
Dec 5, 20260
Dec 4, 20260
Dec 3, 20260
Dec 2, 20260
Dec 1, 20260
Nov 30, 20260
Nov 29, 20260
npm weekly downloads

Trends appear after 7 days of data. Collecting since Dec 3 — 4 daily snapshots so far.

Each point is npm's rolling 7-day download count.

Health Score

65/100Good

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1479156892-root.svg)](https://payloaddirectory.dev/plugins/1479156892-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1479156892-root"><img src="https://payloaddirectory.dev/badge/1479156892-root.svg" alt="Payload Directory"></a>
Updated Dec 5, 2026Created Dec 1, 2026Published Dec 5, 2026

README

payload-video-streaming

Video for Payload CMS, from upload to playback.

Upload straight to Cloudflare Stream, Mux or Bunny Stream, follow encoding in the admin,
and play videos on your site with any player. One plugin for Payload 3 and 4.

npm CI License: MIT Payload 3 and 4

Quick start • Providers • Features • Docs • Examples • Changelog

Why payload-video-streaming

  • One videos collection, any provider. Cloudflare Stream, Mux and Bunny Stream behind the same fields, admin and API. Configure one or several.
  • Uploads skip your server. Files go from the browser straight to the provider, large ones resume after interruptions, and editors can upload many at once.
  • A real admin for video. Upload, processing status, preview, replace, import from URL, a poster picker (any frame, an animated clip or an image), captions (uploaded or AI), extra audio tracks (dubs and other languages) and downloads. It's built from Payload's own components and design tokens, so it fits the admin in light and dark themes on Payload 3 and 4. Editors can also upload straight from any video field.
  • Play it anywhere. React components for video fields, blocks and rich text, with the provider's player or yours (hls.js, Video.js, Vidstack, Mux Player…).
  • Public or private. Visitors watch the videos your pages embed. Signed playback and access hooks decide who sees private ones.
  • Member uploads. Let your site's users upload, with ownership, review before publishing, limits and a drop-in form.
  • Light. Providers are called over REST with fetch: no SDKs at runtime. A built-in fake provider lets you build and test without an account.

Coming from payload-cf-stream? This is its successor. See Migrating from payload-cf-stream.

Quick start

You need Payload ^3.94.0 or ^4.0.0-beta.12 and an account with one of the providers.

1. Install

npm install payload-video-streaming

2. Add the plugin and a provider

This uses Cloudflare Stream; Mux and Bunny work the same way.

// payload.config.ts
import { buildConfig } from 'payload'
import { videoField, videoPlugin } from 'payload-video-streaming'
import { cloudflareStream } from 'payload-video-streaming/cloudflare'

export default buildConfig({
  collections: [
    { slug: 'posts', fields: [{ name: 'title', type: 'text' }, videoField({ name: 'heroVideo' })] },
  ],
  plugins: [
    videoPlugin({
      providers: [
        cloudflareStream({
          accountId: process.env.CLOUDFLARE_ACCOUNT_ID!,
          apiToken: process.env.CLOUDFLARE_STREAM_API_TOKEN!,
        }),
      ],
    }),
  ],
})

Prefer environment variables? videoPlugin(videoOptionsFromEnv()) configures every provider it finds (variables).

3. Regenerate the admin import map

So Payload finds the plugin's components:

npx payload generate:importmap

Upload a video under Videos in the admin. It updates on its own while the provider processes it.

4. Render it on your site

import { Video } from 'payload-video-streaming/react'

const post = await payload.findByID({ collection: 'posts', id, depth: 1 })

<Video video={post.heroVideo} />   // the provider's player, or pass player={YourPlayer}

Anyone who can read the post can watch its video, even though the videos collection itself is only readable by logged-in users by default (who can watch).

Providers

ProviderSetupImport
Cloudflare StreamAccount ID and an API token with Stream · Edit (guide)cloudflareStream() from payload-video-streaming/cloudflare
MuxAn access token with Mux Video: Read and Write (guide)muxVideo() from payload-video-streaming/mux
Bunny StreamLibrary ID, API key and CDN hostname (guide)bunnyStream() from payload-video-streaming/bunny
muxVideo({ tokenId: process.env.MUX_TOKEN_ID!, tokenSecret: process.env.MUX_TOKEN_SECRET! })

bunnyStream({
  libraryId: process.env.BUNNY_STREAM_LIBRARY_ID!,
  apiKey: process.env.BUNNY_STREAM_API_KEY!,
  cdnHostname: process.env.BUNNY_STREAM_CDN_HOSTNAME!,
})

Each guide covers signing keys, webhooks, limits and what was verified against a real account.

What each provider supports

The admin shows only what a video's provider can do, and endpoints for anything else answer 501.

Cloudflare StreamMuxBunny Stream
Browser uploadPOST (≤200 MB) or tusresumable chunked PUTtus, signed by your server
Import by URL, server upload, adopt existing✓✓✓
Encoding progress✓✓ (while transcoding)✓
Signed playback (optional, off by default; one setting per provider)signing key optionalsigning key requiredmatch the library's token authentication
Per-video allowed origins✓——
Posterany frame, GIF clip, imageany frame, WebP clip, image1 of 5 thumbnails, preview, image
Seek previews (storyboard)✓ (generated)✓✓ (generated)
Captionsupload, AI (12 languages)upload, AI (22 languages + auto)upload, AI transcription
Extra audio tracks (from a URL)✓, rename, choose the default✓ (with a language), rename— (from the source file only)
DownloadsMP4 and audio, per videoMP4 and audio, per videoMP4, library-wide
Watermarks (watermarks)profiles, per videooverlay, per videolibrary-wide, in Bunny's dashboard
HLS / DASH✓ / ✓✓ / —✓ / —
Webhooks✓✓✓

All three are tested against real accounts, on Payload 4.0.0-beta.12 and 3.94.2, with SQLite, Postgres and MongoDB (TESTING.md).

[!IMPORTANT] Bunny's standard encoding queue can be slow. On a new library, videos waited at 0% for over 15 minutes; with Premium encoding they were ready in under a minute. More on encoding and limits.

Features

Uploading

Every upload goes straight from the browser to the provider.

  • Videos list: drop one file to upload it and open it. Drop several and they upload as separate videos, 3 at a time, each with progress, pause, cancel and retry.
  • Any video field: "Upload new video" next to the picker uploads and selects the new video without leaving the page.
  • Import from a URL: the provider fetches the file.
  • Replace: the original keeps playing until the replacement is ready.
  • Watermarks: editors manage watermark profiles and choose one per upload, with a default in the options (Cloudflare, Mux; opt in with watermarks). See Watermarks.

Building your own upload UI? useVideoUpload, useUploadQueue and uploadVideoFile handle every provider's protocol (API reference).

Videos in your content

videoField() adds a video to any collection, group or block. videoBlock() is a ready-made block for layout builders and Lexical rich text, with player settings editors can change.

fields: [
  videoField({ name: 'heroVideo' }),
  { name: 'layout', type: 'blocks', blocks: [videoBlock(), /* your blocks */] },
]

Populated videos carry a virtual playback field with their URLs in every REST, GraphQL and Local API read. → Video fields and blocks

Rendering and players

payload-video-streaming/react works in Server and Client Components, without importing Payload or Next.js.

<Video video={post.heroVideo} />                         // a video field
<VideoBlock block={block} />                             // a video block
videoJSXConverters()                                     // video blocks in rich text
<Video video={post.heroVideo} player={HlsJsPlayer} />    // any player
  • Default player: the provider's iframe player, which adds no JavaScript to the page.
  • Your own player: any component that receives { source, options, title }. source.hls works with hls.js, Video.js, Vidstack, native Safari and iOS, ExoPlayer and AVPlayer.

→ Rendering videos, covering your own blocks, a page per video, client-only apps and caching. Ready-made players are in examples/players.

Posters and seek previews

  • Choosing a poster: editors pick it in the video's Poster section. It can be:
    • a frame: scrub the video and use the frame (on Bunny, one of its 5 thumbnails);
    • an animated clip: a looping GIF or WebP;
    • an image: from your media collection, with poster: { imageCollection: 'media' }.
  • Where it shows: every player shows the chosen poster, and source.poster gives it to yours.
  • Seek previews: the thumbnails a player shows while scrubbing are published as a standard WebVTT thumbnails track (source.storyboard). Vidstack, Plyr, Video.js and Media Chrome take it directly, and useStoryboard helps players that don't.

→ Posters and seek previews

Who can watch

  • Video documents follow your collection access. By default, only logged-in users can read them.
  • Embedded videos play for anyone who can read the page they're on. Signed videos, unapproved member uploads and anything access.playback denies are excluded.
  • Signed playback is optional, off by default, and one setting per provider: every video a provider stores is signed or none is.
    • Turn it on with the provider's signedPlayback option (e.g. cloudflareStream({ signedPlayback: true, … })), or for every provider with upload.signedPlayback.
    • Readers who pass access.playback get tokens that outlast the video.
    • Mux needs a signing key. Bunny needs the library's token keys, with token authentication turned on in Bunny. Cloudflare works without a key, through its rate-limited token API.
    • To have both public and signed videos, configure the provider twice with different ids, one of them signed.

→ Who can watch and signed videos

Member uploads

Let your site's users upload their own videos:

  • ownership records each video's uploader.
  • moderation holds new uploads for review.
  • Upload rules limit size and file type, and run your own checks (quotas, for example).
  • <VideoUploader /> is a drop-in upload form for your site.
import { ownerOr, videoPlugin } from 'payload-video-streaming'

const isAdmin = ({ req }) => req.user?.collection === 'users'

videoPlugin({
  providers,
  ownership: true,
  moderation: true,
  upload: { maxFileSize: 2 * 1024 ** 3, allowedTypes: ['video/*'] },
  collection: { access: { create: ({ req }) => Boolean(req.user), update: ownerOr(isAdmin), delete: ownerOr(isAdmin) } },
})

→ Member uploads

Status updates and webhooks

Providers encode in the background. The plugin hears back in any of these ways:

MechanismWhenSetup
Admin pollingWhile an editor has the video openNone
WebhookThe moment the provider finishesnpx payload-video-streaming webhooks --url https://your-site.com
Sync-pending jobOn your schedulesyncPendingTask: { cron: '*/5 * * * *' }
POST /api/videos/sync-pendingFrom any external cronAn authenticated request

The webhooks command prints each provider's URL and setup steps. It can also register Cloudflare's webhook for you (--register cloudflare) and test deployed endpoints (--check). The videos list shows whether each provider's webhook is working. → Webhooks

Lifecycle hooks

React when a video becomes ready or fails, whatever triggered the change:

videoPlugin({
  providers,
  hooks: {
    onReady: async ({ doc, req }) => { /* notify the uploader, publish the post… */ },
    onError: async ({ doc }) => { /* doc.error.code, doc.error.message */ },
  },
})

Server API

import { getVideo } from 'payload-video-streaming'

const videos = getVideo(payload)
await videos.uploadFile({ file: buffer, filename: 'intro.mp4' })
await videos.importFromUrl({ url: 'https://example.com/video.mp4' })
await videos.getPlayback(doc, { expiresIn: 600 })

→ API reference: REST endpoints, the server API, frontend exports and writing a provider.

Orphan cleanup

Find provider videos no document references (a failed delete, deleteFromProvider: false, uploads made elsewhere) and delete them after a review:

npx payload-video-streaming orphans            # dry run: what would be deleted
npx payload-video-streaming orphans --delete

Videos from the last 7 days are skipped, and orphans.creator keeps other apps' videos in a shared account out. Also as getVideo(payload).cleanupOrphans() and an opt-in jobs task. → Orphan cleanup

Documentation

GuideWhat's in it
ConfigurationEvery option and environment variable
Video fields and blocksvideoField(), videoBlock() and the video document
Rendering videosComponents, players, your own blocks, who can watch, signed videos, caching
Member uploadsOwnership, moderation, upload rules, VideoUploader
WebhooksSetup per provider, the CLI, local tunnels, troubleshooting
Audio tracksDubs and other languages: adding from a URL or an upload collection, defaults
Viewing statsViews, watch time, countries and retention from each provider
WatermarksWatermark profiles, choosing one per upload, provider support
Orphan cleanupFinding and deleting provider videos no document references
TranslationsThe admin UI's strings: overriding them and adding languages
API referenceStatuses, REST endpoints, server API, frontend exports, writing a provider
ProvidersCloudflare Stream, Mux, Bunny Stream
ExamplesType-checked configs, Next.js pages, players, upload UIs, server scripts and tests
Migrating from payload-cf-streamMoving existing documents over

Entry points

ImportFor
payload-video-streamingThe plugin, videoField(), videoBlock(), access helpers, getVideo()
payload-video-streaming/cloudflare, /mux, /bunnyProvider factories, plus standalone REST clients, signing and webhook helpers
payload-video-streaming/reactVideo, VideoBlock, videoJSXConverters, VideoUploader, upload and source hooks
payload-video-streaming/clientThe admin components, if you build your own admin views
payload-video-streaming/testingFake providers for your own tests
npx payload-video-streamingwebhooks, fake and migrate-cf-stream commands

Good to know

  • Playback starts once the provider is done: readyToStream turns true. That usually takes seconds to a few minutes.
  • Edits sync to the provider. Changing allowed origins, the poster, the title or meta updates the provider. Signing follows the provider's signedPlayback setting: after changing it, existing videos update when they next sync, or all at once with getVideo(payload).applySigning(). Deleting a document deletes its video there too (deleteFromProvider).
  • Databases: SQLite, Postgres and MongoDB work, and the plugin's writes join your transaction when you pass req.
  • One provider per video. Replacements stay on the same provider; moving videos between providers isn't supported.
  • Provider quirks, such as Cloudflare's single webhook URL, Mux's caption fetching and Bunny's replace behaviour, are listed in each provider guide.

Development

bun install    # installs only; everything else runs on Node
npm run dev    # the admin against a fake provider; no account, containers or database server needed

CONTRIBUTING.md covers the dev app, the fake providers and the test suites. ROADMAP.md lists what's planned. Report security problems privately, as described in SECURITY.md.

License

MIT

Similar plugins