webowodev

payload video stream

by webowodev
Media & images
v3
^3.78.0
MIT

Overview

Summary generated from the README

Adds video streaming to Payload upload collections by sending uploaded videos to a streaming provider, currently Cloudflare Stream, through an adapter. It stores stream metadata in a field on each document and injects a background job that polls the provider until the video is ready. It works alongside S3 storage and can use signed URLs. Requires Payload 3.78 or newer.

Features

  • Cloudflare Stream adapter with an extensible adapter interface for other providers
  • Stream field holding video ID and status of pending, ready or error
  • Background polling task on a dedicated job queue with retries and self-requeuing
  • Optional signed S3 URLs passed to Cloudflare Stream when copying videos
  • Per-collection enablement through plugin configuration
  • TypeScript types for plugin and adapter configuration

Use cases

  • Stream large video files from a Payload media collection without serving them from storage
  • Track whether uploaded videos have finished processing before showing them on a site
  • Combine S3 or R2 storage with Cloudflare Stream for optimized video delivery

From the author

Payload CMS plugin for streaming video uploads to cloud providers like Cloudflare Stream

Installation

npm i payload-video-stream

8

Stars

0

Forks

0

Open Issues

8 months ago

Last Updated

65

Weekly Downloads

v1.3.1

npm Version

113.3 KB

Unpacked Size

0

Dependencies

GitHub stars

80 since Sep 6

Show data
GitHub stars by day (UTC)
DateStars
Dec 5, 20268
Dec 4, 20268
Dec 3, 20268
Dec 2, 20268
Dec 1, 20268
Nov 30, 20268
Nov 29, 20268
Nov 28, 20268
Nov 27, 20268
Nov 26, 20268
Nov 25, 20268
Nov 24, 20268
Nov 23, 20268
Nov 22, 20268
Nov 21, 20268
Nov 20, 20268
Nov 19, 20268
Nov 18, 20268
Nov 17, 20268
Nov 16, 20268
Nov 15, 20268
Nov 14, 20268
Nov 13, 20268
Nov 12, 20268
Nov 11, 20268
Nov 10, 20268
Nov 9, 20268
Nov 8, 20268
Nov 7, 20268
Nov 6, 20268
Nov 5, 20268
Nov 4, 20268
Nov 3, 20268
Nov 2, 20268
Nov 1, 20268
Oct 31, 20268
Oct 30, 20268
Oct 29, 20268
Oct 28, 20268
Oct 27, 20268
Oct 26, 20268
Oct 25, 20268
Oct 24, 20268
Oct 23, 20268
Oct 22, 20268
Oct 21, 20268
Oct 20, 20268
Oct 19, 20268
Oct 18, 20268
Oct 17, 20268
Oct 16, 20268
Oct 15, 20268
Oct 14, 20268
Oct 13, 20268
Oct 12, 20268
Oct 11, 20268
Oct 10, 20268
Oct 9, 20268
Oct 8, 20268
Oct 7, 20268
Oct 6, 20268
Oct 5, 20268
Oct 4, 20268
Oct 3, 20268
Oct 2, 20268
Oct 1, 20268
Sep 30, 20268
Sep 29, 20268
Sep 28, 20268
Sep 27, 20268
Sep 26, 20268
Sep 25, 20268
Sep 24, 20268
Sep 23, 20268
Sep 22, 20268
Sep 21, 20268
Sep 20, 20268
Sep 19, 20268
Sep 18, 20268
Sep 17, 20268
Sep 16, 20268
Sep 15, 20268
Sep 14, 20268
Sep 13, 20268
Sep 12, 20268
Sep 11, 20268
Sep 10, 20268
Sep 9, 20268
Sep 8, 20268
Sep 7, 20268
Sep 6, 20268
npm weekly downloads

16−21 since Sep 6

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 202616
Dec 4, 202618
Dec 3, 202614
Dec 2, 20269
Dec 1, 202625
Nov 30, 202628
Nov 29, 202628
Nov 28, 202629
Nov 27, 202627
Nov 26, 202629
Nov 25, 202633
Nov 24, 202618
Nov 23, 202616
Nov 22, 202620
Nov 21, 202625
Nov 20, 202636
Nov 19, 202642
Nov 18, 202667
Nov 17, 202665
Nov 16, 202668
Nov 15, 202663
Nov 14, 202657
Nov 13, 202650
Nov 12, 202657
Nov 11, 202629
Nov 10, 202630
Nov 9, 202634
Nov 8, 202636
Nov 7, 202653
Nov 6, 202650
Nov 5, 202636
Nov 4, 202635
Nov 3, 202636
Nov 2, 202632
Nov 1, 202655
Oct 31, 202644
Oct 30, 202644
Oct 29, 202643
Oct 28, 202643
Oct 27, 202640
Oct 26, 202641
Oct 25, 202615
Oct 24, 202610
Oct 23, 20268
Oct 22, 20269
Oct 21, 202626
Oct 20, 202625
Oct 19, 202620
Oct 18, 202620
Oct 17, 202621
Oct 16, 202621
Oct 15, 202621
Oct 14, 20265
Oct 13, 20266
Oct 12, 20266
Oct 11, 20268
Oct 10, 20268
Oct 9, 202613
Oct 8, 202613
Oct 7, 202614
Oct 6, 202618
Oct 5, 202624
Oct 4, 202627
Oct 3, 202630
Oct 2, 202630
Oct 1, 202645
Sep 30, 202650
Sep 29, 202666
Sep 28, 202664
Sep 27, 202669
Sep 26, 202680
Sep 25, 202683
Sep 24, 202674
Sep 23, 202670
Sep 22, 202668
Sep 21, 202672
Sep 20, 202665
Sep 19, 202679
Sep 18, 202672
Sep 17, 202674
Sep 16, 202688
Sep 15, 202696
Sep 14, 2026120
Sep 13, 2026122
Sep 12, 202696
Sep 11, 2026108
Sep 10, 2026105
Sep 9, 202692
Sep 8, 202666
Sep 7, 202641
Sep 6, 202637

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

Health Score

51/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/1097556548-root.svg)](https://payloaddirectory.dev/plugins/1097556548-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1097556548-root"><img src="https://payloaddirectory.dev/badge/1097556548-root.svg" alt="Payload Directory"></a>
Updated Apr 5, 2026Created Nov 16, 2025Published Feb 11, 2026

README

Payload Video Streaming Plugin

A Payload CMS plugin that enables seamless video uploads directly to streaming providers from Payload upload collections. This plugin automatically handles video file uploads to streaming platforms, providing optimized video delivery for your Payload CMS applications.

Features

  • 🎥 Direct video uploads to streaming providers from Payload upload collections
  • ☁️ Cloudflare Stream support (currently available)
  • 🔌 Extensible adapter architecture for adding more streaming providers
  • 🔄 Automatic video processing and optimization
  • 📊 Stream metadata integration with Payload documents
  • 🎯 Type-safe configuration with TypeScript support

Supported Providers

Currently supported:

  • Cloudflare Stream - Complete integration with Cloudflare's video streaming platform

Planned support:

  • Mux
  • AWS MediaConvert
  • Azure Media Services
  • Other streaming API providers

Installation

npm install payload-video-stream
# or
yarn add payload-video-stream
# or
pnpm add payload-video-stream

Quick Start

1. Configure the Plugin

Add the plugin to your payload.config.ts:

import { buildConfig } from 'payload/config'
import { videoStream } from 'payload-video-stream'
import { cloudflareStreamAdapter } from 'payload-video-stream/adapters'

export default buildConfig({
  plugins: [
    // configure your s3 storage configuration
    s3Storage({
      bucket: process.env.S3_BUCKET ?? 'romonoa',
      clientUploads: true, // enable client-side uploads
      collections: {
        video: true,
      },
      config: {
        credentials: {
          accessKeyId: process.env.S3_ACCESS_KEY_ID ?? '',
          secretAccessKey: process.env.S3_SECRET_ACCESS_KEY ?? '',
        },
        endpoint: process.env.S3_ENDPOINT,
        region: process.env.S3_REGION,
        // ... Other S3 configuration
      },
      signedDownloads: {
        // expires in 24 hours
        expiresIn: 60 * 60 * 24,
      }, // enable signed download URLs
    }),    

    // configure video stream plugin
    videoStream({
      collections: {
        media: true,
      },

      // configure default adapter, currently only support cloudflare stream adapter
      defaultAdapter: cloudflareStreamAdapter({
        accountId: process.env.CLOUDFLARE_STREAM_ACCOUNT_ID || '',
        apiToken: process.env.CLOUDFLARE_STREAM_API_TOKEN || '',
        customerSubdomain: process.env.NEXT_PUBLIC_CLOUDFLARE_STREAM_CUSTOMER_SUBDOMAIN || '',
        requireSignedURLs: true // OPTIONAL: enable this if you enabled the signed downloads on your storage so the plugin will use the signed s3 url to the cloudflare stream copy video url function
      }),
    }),
  ],
  // ... rest of your config
})

2. Environment Variables

Create a .env file with your streaming provider credentials:

CLOUDFLARE_STREAM_API_TOKEN=your_cloudflare_api_token
CLOUDFLARE_STREAM_ACCOUNT_ID=your_cloudflare_account_id
NEXT_PUBLIC_CLOUDFLARE_STREAM_CUSTOMER_SUBDOMAIN=https://customer-<YOUR_CUSTOMER_ID>.cloudflarestream.com

3. Create a Video Collection

The plugin works with Payload upload collections:

import type { CollectionConfig } from 'payload/types'

export const Videos: CollectionConfig = {
  slug: 'videos',
  upload: {
    mimeTypes: ['video/*'],
  },
  fields: [
    {
      name: 'title',
      type: 'text',
      required: true,
    },
    {
      name: 'description',
      type: 'textarea',
    },
  ],
}

Configuration Options

Plugin Options

type VideoStreamConfig = {
  collections?: {
    [collectionSlug: string]: boolean
  }
  enabled?: boolean
  defaultAdapter: StreamAdapter
  disabled?: boolean
  requireSignedURLs?: boolean
}

Cloudflare Stream Configuration

To use Cloudflare Stream:

  1. Sign up for Cloudflare Stream
  2. Get your Account ID from the Cloudflare dashboard
  3. Create an API token with Stream permissions
  4. Add credentials to your environment variables

Background Jobs & Status Polling

The plugin automatically manages video processing status through Payload's job queue system. When you upload a video, the plugin continuously polls the streaming provider to check when the video is ready for playback.

Automatic Task Injection

The plugin automatically injects background tasks into your Payload configuration. Each streaming adapter gets its own task that runs on the payloadVideoStream queue:

  • Task Name: payloadStreamUpdateStatusFor{AdapterName} (e.g., payloadStreamUpdateStatusForCloudflareStream)
  • Queue Name: payloadVideoStream
  • Behavior: Automatically registered and managed by the plugin
// The plugin injects tasks like this (happens automatically)
config.jobs = {
  ...config.jobs,
  tasks: [
    ...(config.jobs?.tasks || []),
    updateStreamStatusTask(cloudflareStreamAdapter),
  ],
}

How Status Updates Work

  1. Video Upload: When you upload a video to a collection with the plugin enabled:

    • The video is sent to your streaming provider (e.g., Cloudflare Stream)
    • The stream field is populated with metadata (videoId, status: 'pending')
  2. Background Polling: The plugin creates a background task that:

    • Runs periodically on the payloadVideoStream queue
    • Queries the streaming provider for the current video status
    • Updates the document in Payload with the latest status
  3. Self-Requeuing: If the video is still processing:

    • The task automatically re-queues itself on the payloadVideoStream queue
    • Retries with exponential backoff (max 3 retries)
    • Continues until the video reaches ready status
  4. Status Lifecycle:

    • pending → Video is being processed by the provider
    • ready → Video processing complete, ready for playback
    • error → Processing failed

Monitoring Status Updates

You can track video status in several ways:

In the Payload Admin UI:

  • Go to your video collection (e.g., /admin/collections/videos)
  • The stream.status field shows the current status
  • Refresh to see the latest status from the background job

Programmatically:

const video = await payload.findByID({
  collection: 'videos',
  id: videoId,
})

const streamStatus = (video.stream as { status?: string })?.status
// 'pending', 'ready', or 'error'

Queue Configuration

The payloadVideoStream queue is automatically created and configured. No additional setup is required. However, you can monitor queue status through:

  • Payload's admin UI (Jobs panel, if enabled)
  • Your job queue provider's dashboard
  • Application logs

Task Input Parameters

When the plugin queues a status update task, it passes:

  • documentId: The ID of the video document to update
  • collectionSlug: The collection containing the video

Example task payload:

{
  "documentId": "abc123",
  "collectionSlug": "videos"
}

Development

Prerequisites

  • Node.js 18+
  • pnpm (recommended) or npm/yarn
  • A Payload CMS project for testing

Setup

  1. Clone the repository:
git clone https://github.com/webowodev/payload-video-stream.git
cd payload-video-stream
  1. Install dependencies:
pnpm install
  1. Set up the dev environment:
cd dev
cp .env.example .env
  1. Update the .env file with your configuration:
DATABASE_URI=postgres://root:[email protected]:5432/videostream
PAYLOAD_SECRET=your-secret-key
CLOUDFLARE_STREAM_API_TOKEN=your_cloudflare_api_token
CLOUDFLARE_STREAM_ACCOUNT_ID=your_cloudflare_account_id
NEXT_PUBLIC_CLOUDFLARE_STREAM_CUSTOMER_SUBDOMAIN=https://customer-<YOUR_CUSTOMER_ID>.cloudflarestream.com
  1. Start the development server:
pnpm dev

The dev server will be available at http://localhost:3000

Project Structure

payload-video-stream/
├── src/
│   ├── index.ts              # Main plugin export
│   ├── adapters/
│   │   ├── streamAdapter.ts  # Base adapter interface
│   │   ├── cloudflareStream.ts # Cloudflare implementation
│   │   └── types.ts          # Adapter type definitions
│   ├── fields/
│   │   └── stream.ts         # Custom field definitions
│   └── hooks/
│       └── afterOperation.ts # Upload hooks
├── dev/                      # Development Payload instance
│   ├── payload.config.ts
│   └── app/                  # Next.js app router
└── test-results/             # Test output

Testing

Run the test suite:

pnpm test

Run tests in watch mode:

pnpm test:watch

Run integration tests:

pnpm test:int

Run E2E tests:

pnpm test:e2e

Building

Build the plugin for production:

pnpm build

Contributing

We welcome contributions! Here's how you can help:

Adding a New Streaming Provider

  1. Create a new adapter in src/adapters/:
// src/adapters/yourProvider.ts
import type { StreamAdapter } from './streamAdapter'

export class YourProviderAdapter implements StreamAdapter {
  async upload(file: File): Promise<StreamResult> {
    // Implement upload logic
  }
  
  async delete(videoId: string): Promise<void> {
    // Implement delete logic
  }
}
  1. Export your adapter in src/adapters/index.ts

  2. Add configuration types in src/adapters/types.ts

  3. Write tests for your adapter

  4. Update documentation

Contribution Guidelines

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass: pnpm test
  6. Commit your changes: git commit -m 'Add amazing feature'
  7. Push to the branch: git push origin feature/amazing-feature
  8. Open a Pull Request

Code Style

  • Follow the existing code style
  • Use TypeScript for all new code
  • Add JSDoc comments for public APIs
  • Run pnpm lint before committing

Commit Messages

Follow Conventional Commits:

  • feat: New features
  • fix: Bug fixes
  • docs: Documentation changes
  • test: Test additions or changes
  • refactor: Code refactoring
  • chore: Maintenance tasks

Roadmap

  • Cloudflare Stream adapter
  • Mux adapter
  • AWS MediaConvert adapter
  • Azure Media Services adapter
  • Video thumbnail generation
  • Webhook support for processing status
  • Custom video player integration
  • Analytics integration

License

MIT License - see the LICENSE file for details.

Copyright (c) 2025

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Support

Acknowledgments

Built with Payload CMS - The most powerful TypeScript headless CMS.


Made with ❤️ by webowodev

Similar plugins