Stream Media Transformations Workers Binding Released
Key Points
- Workers binding for video transformations now available
- Support for private R2 bucket video processing
- Multiple output modes including video, frames, and audio
Summary
Cloudflare has released a new Workers binding for Stream Media Transformations, enabling video processing directly within Workers. This binding allows developers to resize, crop, extract frames, and extract audio from videos stored anywhere, including private R2 buckets.
Key Points
- Private source support: Transform videos from protected sources like R2 buckets
- Multiple output modes: Support for video (MP4), frame (images), spritesheet, and audio (M4A) extraction
- AI integration: Extract frames for classification or audio for transcription using Workers AI
- Direct R2 optimization: Process and store optimized videos back to R2 for reuse
Configuration
Add the binding to your wrangler.toml:
[media]
binding = "MEDIA"
Usage Example
const video = await env.R2_BUCKET.get("input.mp4");
const result = env.MEDIA
.input(video.body)
.transform({ width: 480, height: 270 })
.output({ mode: "video", duration: "5s" });
return await result.response();