Video Tasks
Introduction
Video files are commonly used in <video> tags on the web, or as input for mobile, TV, and other media players on a range of devices.
You can use video tasks to:
- Convert video files to different formats for broader compatibility
- Compress video files to save bandwidth
- Resize video files to fit different screen sizes
- Add text and image overlays to video files
Creating a video task
Provide a url and set kind to video. All processing options go inside the options object.
Default settings
If you don't specify any options, the default task will create a new video file with the following settings:
| Setting | Default Value |
|---|---|
| Width | Same as input file |
| Height | Same as input file |
| Frame Rate | Same as input file, where possible 1 |
| Video Codec | h264 |
| Audio Codec | aac |
| Container | mp4 |
| Bitrate | Auto-selected for quality/size balance |
| Duration | Full video (no trimming) |
| Overlays | None |
If you just want to normalise uploaded videos for web playback, this is a reasonable set of defaults.
We always place the moov atom to the start of output files, as this enables preload="metadata" and helps with playback issues on some devices.
Video options
Video tasks support the following optional properties inside the options object.
Here's a comprehensive example:
Width
The width of the video to encode in pixels or as a percentage of the input file. 2
If you specify a percentage (e.g. "50%"), the output width will be relative to the input width.
Height
The height of the video to encode in pixels or as a percentage of the input file.
Fit
How the video should be scaled to fit the width and height.
Available fits are:
fill: (default) Stretch the video to fit the exact dimensions, even if that distorts the aspect ratio.cover: Scale the video up to cover the dimensions while preserving aspect ratio. May crop.contain: Scale the video down to fit within the dimensions while preserving aspect ratio. May add padding.
If only one of width or height is specified, the other will be calculated to maintain the original aspect ratio and fit will be ignored.
Position
Used in conjunction with fit: cover or fit: contain to specify where the video is placed within the output frame.
Available positions: center (default), top, bottom, left, right, top left, top right, bottom left, bottom right.
Background
Used with fit: contain to specify the color used to fill extra space. Specified as a hex color.
Default is black (#000000).
FPS
The frame rate of the output video. Must be a number between 1 and 60.
If not specified, the frame rate matches the input file.
If you require more granular control over output frame rates, please contact us and we can activate on an org-by-org basis.
Format
The output container format.
Available formats: mp4, webm.
Codec
The video codec to use.
Available codecs: h264, h265, vp9, av1.
Quality
The desired quality of the output video.
Available values: very_low, low, medium, high, very_high.
Start
From where in the video to start encoding, in seconds.
End
Where in the video to stop encoding, in seconds.
You can combine start and end to output a specific segment of the input file.
Layers
Layers add text and image overlays to the output video. The layers option accepts an array of layer objects.
Supported Inputs
Input files can contain:
| Property | Values |
|---|---|
| Video Stream Codec | h264/avc, h265/hevc, vp8, vp9, av1 |
| Audio Stream Codec | aac, opus, mp3, flac, vorbis |
| Media Container | mp4, webm, mov, avi, mkv |
Limits
Output files can be:
- up to
4096pxon the longest edge - up to
16MPin total pixels - up to
4 hoursin duration - up to
4TBin size
Footnotes
-
h264 has different profiles, each with different limitations on the resolution and frame rates supported (see Levels). We default to
Highprofile atLevel 4.1, for the broadest compatibility (see, for example, Apple Authoring Guidelines for Video or Google TV support). If the requested dimensions or framerate require, and the input file supports it, we can use up toHighprofile atLevel 5.2(supports 4k@60fps). ↩ -
It's not a hard and fast rule, but ideally your output video dimensions should be a multiple of 16. This is because h264 and vp9 codecs use 16x16 pixel blocks to encode the video. ↩