INTEGRITY Cloudflare Docs

Transform videos

You can optimize and manipulate videos stored outside of Cloudflare Stream with Media Transformations. Transformed videos and images are served from one of your zones on Cloudflare.

To transform a video or image, you must enable transformations for your zone. If your zone already has Image Transformations enabled, you can also optimize videos with Media Transformations.

Getting started

You can dynamically optimize and generate still images from videos that are stored outside of Cloudflare Stream with Media Transformations.

Cloudflare will automatically cache every transformed video or image on our global network so that you store only the original image at your origin.

To enable transformations on your zone:

  1. In the Cloudflare dashboard, go to the Transformations page.

    Go to Transformations ↗
  2. Locate the specific zone where you want to enable transformations.

  3. Select Enable for the zone.

Transform a video by URL

You can convert and resize videos by requesting them via a specially-formatted URL, without writing any code. The URL format is:

https://example.com/cdn-cgi/media/<OPTIONS>/<SOURCE-VIDEO>

For example, this URL will source an HD video from an R2 bucket, shorten it, crop and resize it as a square, and remove the audio.

https://example.com/cdn-cgi/media/mode=video,time=5s,duration=5s,width=500,height=500,fit=crop,audio=false/https://pub-8613b7f94d6146408add8fefb52c52e8.r2.dev/aus-mobile-demo.mp4

The result is an MP4 that can be used in an HTML video element without a player library.

Options

mode

Specifies the kind of output to generate.

time

Specifies when to start extracting the output in the input file. Depends on mode:

duration

The duration of the output video or spritesheet. Depends on mode:

fit

In combination with width and height, specifies how to resize and crop the output. If the output is resized, it will always resize proportionally so content is not stretched.

height

Specifies maximum height of the output in pixels. Exact behavior depends on fit.

width

Specifies the maximum width of the image in pixels. Exact behavior depends on fit.

audio

When mode is video, specifies whether or not to include the source audio in the output.

When mode is audio, audio cannot be false.

format

If mode is frame, specifies the image output format.

If mode is audio, specifies the audio output format.

filename

Specifies the filename to use in the returned Content-Disposition header. If not specified, the filename will be derived from the source URL.

Source video requirements

Limitations

When using Media Transformations from a Cloudflare Worker, we recommend using the bindings. Otherwise, if the Worker is calling Media Transformations on the same zone used as its trigger, apply the global_fetch_strictly_public compatibility flag to avoid 404 errors on /cdn-cgi/media paths.

Pricing

After November 1st, 2025, Media Transformations and Image Transformations will use the same subscriptions and usage metrics.