変更履歴 — Cloudflare の新しい更新と改善。RSSを購読 | RSSフィードを表示 ← すべての記事に戻る
Workers向け Stream バインディングの紹介
公開日: 2026年5月7日
カテゴリ: Stream
新しい Workers 用の Stream バインディングを使って、Stream のビデオライブラリと直接やりとりできるようになりました。これにより、Worker から認証された API コールを行うことなく、Stream へのコンテンツアップロード、直接アップロードの発行、ビデオ管理、署名付き URL の生成が可能になります。Stream と Workers をより密接に統合することで、より多くのプログラム的パイプライン、緊密な統合、生成 AI や推論ワークロードのサポートが可能になります。
次の場合に Stream バインディングを使用してください:
- URL からビデオをアップロードする、またはエンドユーザー向けに基本的な直接アップロードリンクを作成する
- 署名鍵を管理せずに再生用の署名トークンを生成する
- ビデオのメタデータ、キャプション、ダウンロード、ウォーターマークを管理する
- Workers 内だけでビデオパイプラインを構築する
はじめ方: Wrangler 設定に Stream バインディングを追加
wrangler.jsonc
{
" $schema " : "./node_modules/wrangler/config-schema.json" ,
" stream " : {
" binding " : "STREAM"
}
}
wrangler.toml
[ stream ]
binding = "STREAM"
AI でビデオを生成して Stream に直接アップロードする、または既存ファイルの URL を送る
JavaScript
const aiResponse = await env . AI . run ( "google/veo-3.1" , {
prompt : "A dog walking next to a river" ,
duration : "10s" ,
aspect_ratio : "16:9" ,
resolution : "1080p" ,
generate_audio : true ,
}, {
gateway : { id : "experiments" },
} ) ;
const videoUrl = aiResponse . result . video ;
const streamVideo = await env . STREAM . upload ( videoUrl ) ;
TypeScript
const aiResponse = await env . AI . run ( 'google/veo-3.1' , {
prompt : 'A dog walking next to a river' ,
duration : '10s' ,
aspect_ratio : '16:9' ,
resolution : '1080p' ,
generate_audio : true ,
}, {
gateway : { id : 'experiments' },
} ) ;
const videoUrl = aiResponse . result . video ;
const streamVideo = await env . STREAM . upload ( videoUrl ) ;
署名付き URL を署名鍵や API コールなしで生成する
JavaScript
const video_id = "ce800be43a9772f4bb02f35b860fb516"
const token = await env . STREAM . video ( video_id ) . generateToken ()
// Use the "token" in an iframe embed code, manifest URL, or thumbnail:
const embedUrl = `https://customer-igynxd2rwhmuoxw8.cloudflarestream.com/${ token }/iframe`
TypeScript
const video_id = 'ce800be43a9772f4bb02f35b860fb516'
const token = await env . STREAM . video ( video_id ) . generateToken ()
// Use the "token" in an iframe embed code, manifest URL, or thumbnail:
const embedUrl = `https://customer-igynxd2rwhmuoxw8.cloudflarestream.com/${ token }/iframe`
ビデオプロパティの取得と設定
JavaScript
const video_id = "46c8b7f480d410840758c1cb14a72e47"
const result = await env . STREAM . video ( video_id ) . details ()
await env . STREAM . video ( video_id ) . update ( {
meta : { name : "sample video" },
} )
TypeScript
const video_id = '46c8b7f480d410840758c1cb14a72e47'
const result = await env . STREAM . video ( video_id ) . details ()
await env . STREAM . video ( video_id ) . update ( { meta : { name : 'sample video' } } )
セットアップ手順と完全な API リファレンスについては、Bind to Workers API を参照してください。
Agent で始める
- Cloudflare Stream(env.STREAM)のバインディングを追加します。
- watch ページでは、Stream バインディングを使用して ID に基づく情報を取得し、video.meta.name をページタイトルとして利用できます。
© 2026 Cloudflare, Inc. プライバシーポリシー 利用規約