Video API Reference

Our Video API allows you to automatically transform your videos into a streamable format that can be viewed using a web player, on any browser, on any device.

This section of the documentation describes all of the parameters available in the imgix Video API and includes code samples that you can play with. For more instructional information about how to implement video such as setting up a web player, please see the Tutorials section.

Video Processing

When a video is uploaded to your Source's origin, imgix will automatically detect new video files in your origin assets to be processed by our service.

Once new videos are detected, imgix will begin transcoding videos into hls format. This will enable you to apply parameters to your video URLs. For more information on the hls format, click here.

The processing time will vary depending on the video's length. Processing progress can be tracked in the Asset Manager, where videos are marked one of the following status states:

  • Processing: The video is currently being processed by our service
  • Processed: The video has been successfully converted and can now be served through the imgix.video domain (or your custom imgix domain)
  • Error: There was an issue processing the video

A video will return an error state if the video is incompatible or if there are issues with accessing the video. To ensure consistent video transcoding, it is recommended to not rename or remove video once it has been uploaded to your origin.

Removing a Video

Unlike the rendering API, videos will continue to be scanned for availability at your origin. If a video is removed from your origin, the following will happen:

  • The video URL will no longer support playback
  • The asset's status will change to deleted in the Asset Manager

Limits

The max duration for any single asset is 12 hours. For more information about standardizing video inputs, see our guide on optimizing video performance.

Using Videos in a Web Player

When no parameter is applied, a .video URL will return a 404 response. Applying the parameter fm=hls will cause the video to be formatted to a format that can be played using a web player.

Here is a code example that uses a player to stream imgix videos:

        
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest">
<video id="my-player" controls="controls" style="width: 100%; max-width: 1500px;" crossorigin="anonymous"/>
<script>
  let video = document.querySelector("#my-player");
  let src = "https://assets.imgix.video/videos/girl-reading-book-in-library.mp4?fm=hls";

  if (video.canPlayType("application/vnd.apple.mpegurl")) {
    video.src = src;
  } else if (Hls.isSupported()) {
    let hls = new Hls();

    hls.loadSource(src)
    hls.attachMedia(video);
  } else {
    console.error("This is a legacy browser that doesn't support Media Source Extensions");
  }
  
</script>
        
      

This will create the video player below:

Click here to modify this in a Codepen.

Format