ClaudeCloudflare Developer PlatformMar 18, 2026, 12:00 AM

Stream - Media Transformations binding for Workers

A condensed section focused on the key takeaways first.

Original Post

Quick Digest

Summary

A condensed section focused on the key takeaways first.

claudeenmodel: claude-sonnet-4-20250514

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();

Full Translation

Translations

A translation section that keeps the flow of the original article.

claudejamodel: claude-sonnet-4-20250514

Stream - Workers向けMedia Transformationsバインディング

Changelog

Cloudflareの新しいアップデートと改善。RSSを購読 RSSフィードを表示

← すべての投稿に戻る

Workers向けMedia Transformationsバインディング

2026年3月18日 | Stream

Workersバインディングを使用してMedia Transformationsで動画を変換できるようになりました。これにより、R2バケットなどのプライベートな場所を含む、どこに保存されている動画でもリサイズ、クロップ、フレーム抽出、音声抽出が可能になります。

Media Transformationsバインディングは以下の場合に便利です:

  • プライベートまたは保護されたソースに保存された動画の変換
  • 動画を最適化し、再利用のために出力を直接R2に保存
  • Workers AIでの分類や説明のための静止フレームの抽出
  • Workers AIを使用した転写のための音声トラックの抽出

使用開始

Wrangler設定にMediaバインディングを追加します:

wrangler.jsonc

{
  "$schema": "./node_modules/wrangler/config-schema.json",
  "media": {
    "binding": "MEDIA"
  }
}

wrangler.toml

[media]
binding = "MEDIA"

次に、Workerでバインディングを使用して動画を変換します:

JavaScript

export default {
  async fetch(request, env) {
    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();
  },
};

TypeScript

export default {
  async fetch(request, env) {
    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();
  },
};

出力モードには、最適化されたMP4クリップ用のvideo、静止画像用のframe、複数フレーム用のspritesheet、M4A抽出用のaudioがあります。

詳細については、Media Transformationsバインディングドキュメントを参照してください。