Media Transformations: On-the-fly video optimization without the migration
Cloudflare has launched Media Transformations, a new service that applies the same on-the-fly optimization model used by Image Transformations to short-form video. The service targets customers who want to optimize and deliver small MP4 files from their existing storage—whether that's R2, S3, or another origin—without uploading those assets to a managed video pipeline first.
Why not just use Stream?
Cloudflare Stream has offered a full managed video pipeline since 2018, but its adaptive bitrate encoding and HLS packaging features offer diminishing returns for short content or small files. For high-volume use cases like generative AI output, e-commerce product videos, social media clips, or short marketing content, uploading every asset to Stream isn't always practical. Media Transformations instead fetches content directly from the customer's origin, optimizes it quickly, and delivers efficient MP4 files—a workflow that mirrors how Cloudflare Images already handles still images.
The line between image and video can get blurry—consider an animated GIF. Media Transformations lets customers treat product videos and images with similar tools on identical infrastructure. A jacket on an e-commerce site, for example, might use a video as the first "image" in a carousel so shoppers can see how it flows.
Getting started and URL structure
Any zone already enabled for Image Transformations is automatically enabled for Media Transformations. For new zones, navigate to "Transformations" under Stream or Images in the dashboard and click Enable—the toggle affects both Images and Media transformations.
The URL pattern follows Image Transformations but uses the media endpoint instead of image:
https://[your-site]/cdn-cgi/media/<OPTIONS>/<SOURCE-VIDEO>
The <OPTIONS> component is a comma-separated list of key=value flags. Noteworthy options include:
mode:video(the default) outputs a video;framepulls a still image from a single frame;spritesheetgenerates a multi-frame image for seek previews or storyboards.time: specifies the exact start time in the input video to extract a frame or begin a clip.duration: limits the output video length, producing a clip shorter than the original.fit,height,width: control resizing and cropping of the output.audio: set tofalseto remove sound.
The <SOURCE-VIDEO> is a full URL to the source file, or a root-relative path if the origin is on the same zone as the transformation request.
Practical examples
A 30 MB video shot on a phone and stored in R2 demonstrates the service's savings. The original file can be embedded directly from R2, or transformed on the fly with a width adjustment to match a blog post template:
https://[your-site]/cdn-cgi/media/width=600/https://pub-d9fcbc1abcd244c1821f38b99017347f.r2.dev/aus-mobile.mp4
The same video, resized and optimized, comes in at under 4 MB—a significant bandwidth savings. For a context where the video plays as a background, options can be combined to remove audio, shorten length, and crop vertically:
https://[your-site]/cdn-cgi/media/audio=false,duration=10,height=1280,width=720/https://pub-d9fcbc1abcd244c1821f38b99017347f.r2.dev/aus-mobile.mp4
For product carousels, a thumbnail can be generated as a static image from a specific point in the video using mode=frame and time, with the same resizing options applied to the still frame.
Developers can try the service with a sample asset from R2 or their own content. A URL generator tool built on the Streamlit Python framework and running on Workers is also available.
Beta limitations and input constraints
The initial beta enforces the following input limits:
- Files must be smaller than 40 MB.
- Files must be MP4s and should be h.264 encoded.
- Generated video and image variants are cached; original content is not cached during beta, so regenerating a variant triggers a request to the origin.
Cloudflare expects to right-size these limitations based on early customer usage.
Underlying architecture
Unlike Stream, Media Transformations processes requests on the customer's own website domain. Internally, requests are passed to the same On-the-Fly Encoder (OTFE) platform that powers Stream Live. Stream team–built modules act as entry points, performing initial validation on URL formatting and flags before building a request to Stream's Delivery Worker, which invokes OTFE's transformation handlers.
The original asset is fetched from the customer's origin, validated for size and type, and passed to the same OTFE methods that manipulate and optimize video frames and still thumbnails for Stream uploads. A final inspection checks media type and encoding compatibility before the requested variant is generated. Errors produce HTTP error codes similar to Image Transformations. Successful results are cached and delivered as a single file, and even uncached requests complete faster than the video's play time.
Pricing
Media Transformations is free during beta, which is expected to run into Q3 2025. After beta, the service will use the same subscription and billing structure as Image Transformations, including a free monthly allocation per zone of 5,000 transformation operations and a rate of $0.50 per 1,000 unique operations beyond that.
A still frame generated from video counts as one transformation. An optimized video counts as one transformation per second of output video. Each unique transformation is billed once per month, regardless of how many times the resulting variant is served.
For example, a transformed 15-second video, a transformed 10-second silent vertical clip, and one still frame would count as 26 transformations total, billed once per month even if the page receives unlimited visitors.
Roadmap
Near-term work focuses on sizing input limits based on real customer usage and adding a caching layer for origin fetches to reduce egress fees from third-party storage providers. Longer-term plans involve unifying Images and Media Transformations to streamline the developer experience, feature set, and enablement across both services.



