リンクでアップロード
クラウドストレージバケットに保存されている動画がある場合、ファイルのHTTPリンクを渡すことで、Streamがあなたの代わりにファイルを取得します。
動画へのリンクを使用して、Stream APIにPOSTリクエストを送信します。
curl \--data '{"url":"https://storage.googleapis.com/zaid-test/Watermarks%20Demo/cf-ad-original.mp4","meta":{"name":"My First Stream Video"}}' \--header "Authorization: Bearer <API_TOKEN>" \https://api.cloudflare.com/client/v4/accounts/{account_id}/stream/copyStreamは動画をダウンロードしてエンコードする必要があり、動画の長さによっては数秒から数分かかることがあります。
readyToStreamの値がtrueを返すと、動画はストリーミングの準備が整ったことになります。
オプションで、webhooksを使用して、動画がストリーミングの準備ができたときやエラーが発生したときに通知を受け取ることができます。
{ "result": { "uid": "6b9e68b07dfee8cc2d116e4c51d6a957", "thumbnail": "https://customer-f33zs165nr7gyfy4.cloudflarestream.com/6b9e68b07dfee8cc2d116e4c51d6a957/thumbnails/thumbnail.jpg", "thumbnailTimestampPct": 0, "readyToStream": false, "status": { "state": "downloading" }, "meta": { "downloaded-from": "https://storage.googleapis.com/zaid-test/Watermarks%20Demo/cf-ad-original.mp4", "name": "My First Stream Video" }, "created": "2020-10-16T20:20:17.872170843Z", "modified": "2020-10-16T20:20:17.872170843Z", "size": 9032701, "preview": "https://customer-f33zs165nr7gyfy4.cloudflarestream.com/6b9e68b07dfee8cc2d116e4c51d6a957/watch", "allowedOrigins": [], "requireSignedURLs": false, "uploaded": "2020-10-16T20:20:17.872170843Z", "uploadExpiry": null, "maxSizeBytes": 0, "maxDurationSeconds": 0, "duration": -1, "input": { "width": -1, "height": -1 }, "playback": { "hls": "https://customer-f33zs165nr7gyfy4.cloudflarestream.com/6b9e68b07dfee8cc2d116e4c51d6a957/manifest/video.m3u8", "dash": "https://customer-f33zs165nr7gyfy4.cloudflarestream.com/6b9e68b07dfee8cc2d116e4c51d6a957/manifest/video.mpd" }, "watermark": null }, "success": true, "errors": [], "messages": []}動画がアップロードされた後、上記の例のレスポンスに表示される動画のuidを使用して、Streamビデオプレーヤーを使って動画を再生できます。
独自のプレーヤーを使用する場合や、モバイルアプリで動画をレンダリングする場合は、独自のプレーヤーを使用するを参照してください。