Automatically generates cover images for video uploads in specified collections. This feature was written in a linux environment, before the payload video component (that has a cover image as well) It can extract any frame from the video for the cover image (payload component takes the first frame), and can be used to extract many frame for any purpose. This feature was implemented in the flowing way:
npm add @shefing/cover-image
plugins: [
videoCoverPlugin({
collections: ['media', 'videos'], // Collections to process
framePosition: 'middle', // 'start' | 'middle' | number (seconds)
imageFormat: 'webp', // 'webp' | 'jpg' | 'png'
})
]or for default values
plugins: [
videoCoverPlugin({})
]/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
serverSourceMaps: true,
},
serverExternalPackages: [
"ffmpeg-static",
"fluent-ffmpeg"
],
};
export default withPayload(nextConfig);# Copy ffmpeg-static binaries
COPY --from=builder /app/node_modules/ffmpeg-static/ ./node_modules/ffmpeg-static/ npm install fluent-ffmpeg@2.1.2 ffmpeg-static@5.1.0-
When a video is uploaded to a configured collection:
- Extracts a frame at the specified
framePosition - Generates a cover image in the chosen
imageFormat - Stores the image in your
mediacollection
- Extracts a frame at the specified
-
Auto-adds fields to your collections:
{ coverImage: string | Media; // Reference to the generated image thumbnailURL: string; // Direct URL to the thumbnail startPosition: number; // Actual frame position used }
- 🎥 Automatic thumbnail generation for video uploads
- ⚙️ Configurable frame capture position (
start,middle, or custom seconds) - 🖼️ Multiple image formats (WebP, JPEG, PNG)
- 🐳 Docker-ready configuration
- 🛠️ Auto-adds required fields (
coverImage,thumbnailURL,startPosition)
- Fix on Ubuntu/Debian:
sudo apt-get install ffmpeg
- Fix on MacOS:
brew install ffmpeg
- Docker Build Fix:
Ensure yourDockerfileincludes:RUN apt-get update && apt-get install -y ffmpeg COPY --from=builder /app/node_modules/ffmpeg-static/ ./node_modules/ffmpeg-static/
See the consolidated ROADMAP.md at the repo root and the live RoadMap issues for Cover Image.
- Cross-platform support — detect ffmpeg from
process.env.FFMPEG_PATHfirst, fall back toffmpeg-static; document macOS/Windows/Docker setup. - Multiple frames / sprite sheet —
frames: number | number[]for hover previews & chapter thumbnails. - Async / background generation via a Payload job/queue.
- Auto-poster + GIF preview outputs.
- Image processing options (target size, quality, blur, watermark overlay).
- Regenerate action available on each video document.
- Pluggable extractor (
extractor: 'ffmpeg' | 'cloudinary' | custom). - Deprecation guide once Payload's native video cover covers all use-cases.
MIT © Shefing