Getting StartedBest PracticesNormalizing Video Input for the Web

Normalizing Video Input for the Web

The Video API accepts a wide range of video formats and codecs and transcodes your source on demand, so you can serve most video files without any pre-processing. Imgix adapts quality to each source automatically, and for the majority of videos it produces near-optimal output on its own.

Conforming your source to the guidelines below is optional. It can shorten processing time and give you more predictable results, but it is not required.

Acceptable Video File Formats

Imgix accepts any common video file format as input. To ensure your videos are processed correctly, set an appropriate video content type both in the file’s metadata and in the response headers your Origin returns when the video is requested.

What Produces the Best Results

  • Resolution up to 4096x4096: 4096 px per side is the maximum output dimension. Larger sources are scaled down to fit, preserving aspect ratio.
  • H.264 source: H.264 is the most widely compatible codec and the fastest to process. Imgix also accepts H.265/HEVC, AV1, VP9, and others, and transcodes them for you. Sources already encoded in an efficient codec are compressed further automatically.
  • SDR color: Standard dynamic range is the safest default. HDR sources are supported and tone-mapped where needed.

For most videos, no preparation is needed. Imgix’s quality system produces excellent output from standard H.264 source without any manual tuning.

Preparing Video Yourself (Optional)

If you want to conform your video before serving it, a few tools can help.

Using ffmpeg

ffmpeg is an open-source command-line tool for modifying video files. To re-encode a video to a web-friendly 1080p H.264 file:

  1. Install ffmpeg.
  2. In your terminal, navigate to the folder that contains your video.
  3. Assuming input.mp4 is your source and out.mp4 is the output, run:
ffmpeg -i input.mp4 -c:a copy -vf "scale=w=min(iw\,1920):h=-2" -c:v libx264 \
-profile high -b:v 7000k -pix_fmt yuv420p -maxrate 16000k out.mp4

Adjust the presets to suit your content.

Recording on a mobile device

Most mobile devices capture H.264 8-bit video by default. When recording video you plan to serve with the Video API:

  • Record in SDR rather than HDR.
  • 1080p is a good target. Larger sources, such as 4K, are scaled down when served.

Non-Standard Input

Imgix transcodes any valid video source, whether or not it matches the guidelines above. Unusual or high-complexity input may take a little longer to process.