MantisDocs

Cloudflare Stream

Upload a video straight to Cloudflare Stream, let it transcode, and play it from a short-lived signed link.

A video can also go to Cloudflare Stream instead of being packaged by your own ffmpeg. The browser (or your server) uploads the source file straight to Stream over a resumable link, Stream transcodes it, tells Mantis when it is ready, and every playback link is a signed Stream link made per view. You keep the same video id, the same folder rules and the same playbackUrl call.

intro.mp4
  │  tus upload, resumable, straight from the browser or your server
  ▼
Cloudflare Stream     transcodes 360p to 1080p (capped at the source)
  │  webhook: ready, or failed
  ▼
Mantis                records it under lessons/intro
  │  playbackUrl('lessons/intro')
  ▼
the player            a signed HLS link that ends after its lifetime

An id that already holds an HLS package stays HLS: playbackUrl answers Mantis's own link for it, and a Stream upload to that id is refused with 409.

The folder

The id is a folder and a name, like lessons/intro. The folder must take video/*, and its insert, read and delete rules apply to Stream videos as to files. owner is whoever started the upload.

Upload

POST /v1/storage/videos/uploads with the secret key, or with the publishable key and the user's token, answers a tus link the client sends the file to:

request
{
  "video": "lessons/intro",
  "size": 734003200,
  "contentType": "video/mp4",
  "maxDurationSeconds": 3600,
  "allowedOrigins": ["lingua-ly.com", "*.lingua-ly.com"]
}
201
{
  "video": "lessons/intro",
  "uploadUrl": "https://upload.cloudflarestream.com/tus/…",
  "maxDurationSeconds": 3600,
  "expiresAt": "2026-11-08T18:00:00Z"
}
  • The link lives six hours and takes files up to 30 GB; any tus client resumes it after a dropped connection. Send chunks of at least 5 MB, in multiples of 256 KB.
  • maxDurationSeconds is the longest the video may run: one hour unless you ask, at most four hours. A longer video fails.
  • allowedOrigins lists the sites that may play it in a browser, without https://. Without it, any site may.

From Laravel:

$upload = Mantis::storage()->videoUpload('lessons/intro', $size);
$upload = Mantis::storage()->uploadVideoFile('lessons/intro', $path);

MANTIS_VIDEO_ORIGINS=lingua-ly.com,*.lingua-ly.com sets the sites once.

Ready

POST /v1/storage/videos/status with {"video": "lessons/intro"} answers uploading, ready or failed, with the duration once Stream has it. Asking for a playback link before then is refused with 409.

Playback

POST /v1/storage/playback with {"video": "lessons/intro", "expiresIn": 3600} answers a link like https://customer-….cloudflarestream.com/<token>/manifest/video.m3u8. It lives an hour unless you ask for 1 second to 24 hours. Play it with hls.js, or Safari's own <video>; every variant and segment in it is signed by Stream.

  • The folder's read rule is checked when the link is made. The link then plays for anyone who holds it until it ends; userId does not lock a Stream link to one viewer the way it locks an HLS package's.
  • allowedOrigins stops other websites from playing the video in a browser. A request without an Origin, from a script or a native app, still plays with a valid token.
  • Downloads and captions are off.

Delete

POST /v1/storage/delete with {"path": "lessons/intro"} deletes it on Stream too.

Limits

Stored Stream minutes count against the team's plan: 60 on Free, 1,000 on Pro. A video counts its real duration once ready, and its maxDurationSeconds while it uploads. Past the plan, an upload link is refused with 402.

On this page