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
Required props
As with all Tasks, you must provide:
- either a file_idor aurlto use as the input file
- the kindof task to create
File ID
The file_id should be the unique ID of a file in your project's Files collection.
e.g. "file_id": "file_abcdefgh1234"
URL
The url should be the URL of the video file to process.
This should be a publicly accessible or signed URL.
e.g. "url": "https://example.com/video.mp4"
Kind
For video tasks, this is always video.
e.g. "kind": "video"
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.
Shared options
All tasks support the following (optional) props:
- filename
- folder
- ref
See the Tasks documentation for more information on these options.
Video options
Video tasks support a number of optional properties, which are used to control the output video.
If you want to go wild you can create a video with a custom width, height, fit, position, background, fps, format, start, and end ... then add some overlays.
Width
The width of the video to encode in pixels or as a percentage of the input file. 2
If you specify a percentage, the output file's width will be relative to the input file's width. For example, if the input file is 1920x1080, and you specify "width": "50%", the output file will be 960px wide.
Height
The height of the video to encode in pixels or as a percentage of the input file.
If you specify a percentage, the output file's height will be relative to the input file's height. For example, if the input file is 1920x1080, and you specify "height": "50%", the output file will be 540px tall.
Fit
How the video should be scaled to fit the width and height.
Available fits are:
- fill: (default) This will stretch the video to fit the width and height values given, even if that changes the aspect ratio and distorts the video.
- cover- This will scale the video up to cover the width and height given. Therefore, the output video may be cropped but it will retain the original aspect ratio.
- contain- This will scale the video down to fit the width and height given. Therefore the output video may have extra empty padding but the aspect ratio will be preserved.
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, this will specify the position of the video within the width and height.
Available positions are:
- center: (default) The video will be scaled to fit the width and height, and then centered within the output frame.
- top|- bottom: The video will be placed against the top or bottom of the output frame, and centered horizontally (same as passing- top centeror- bottom center).
- left|- right: The video will be placed against the left or right of the output frame, and centered vertically (same as passing- center leftor- center right).
- top left|- top right|- bottom left|- bottom right: The video will be placed against both edges specified.
If only one of width or height is specified, the other will be calculated to maintain the original aspect ratio. Then position will have no effect and will be ignored.
Background
Used in conjunction with fit: contain, this will specify the color used to fill any extra space in the output frame.
The background color is specified as a hex color.
If not specified, the background will be black (hex color: #000000).
If only one of width or height is specified, or any value other than fit: contain is passed in, then background will have no effect and will be ignored.
FPS
The frame rate of the output video in frames per second. The value should be a number (integer or float) between 1 and 60.
If not specified, the frame rate will be the same as the input file.
If the input file has a frame rate that is not supported by the output format, the frame rate will be converted to the nearest supported value.
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 format of the video to encode. Shorthand for container and codec.
Available formats are:
- mp4(shorthand for- "container": "mp4", "codec": "h264")
- webm(shorthand for- "container": "webm", "codec": "vp9")
Codec
The codec of the output video.
Available codecs are:
- h264(audio will use- aacaudio codec)
- vp9(audio will use- opusaudio codec)
If you require hevc, av1, or other codec support, please contact us and we can activate on an org-by-org basis.
Container
The container of the output video.
Available containers are:
- mp4
- webm
Whilst you can technically specify a vp9 codec inside an mp4 container, or h264 codec inside a webm container, these files are not supported by all players.
Quality
The desired quality of the output video. This is a number between 1 and 100, and it's a relative scale to the input file's quality.
Default is 80, which balances quality and filesize.
Start
From where in the video to start encoding in seconds.
If not specified, the video will start at the beginning of the input file.
If your value is greater than the input file duration, the task will fail.
End
Where in the video to stop encoding in seconds.
If not specified, the video will be encoded to the end of the input file.
If your value is greater than the input file duration, the output file will stop at the end of the input file.
Duration
The duration of the output video in seconds. An alternative to end.
If not specified, the video will be encoded to the end of the input file.
If your value is greater than the input file duration, the output file will stop at the end of the input file.
You can combine start and end, start and duration, or end and duration props. This gives you a lot of flexibility to output a specific segment of the input file.
Layers
Layers are used to add text and image overlays to the output video. The layers prop accepts an array of layer objects.
Note: we're adding a complete guide to layers, packed with visual examples, soon. If you'd like to see an early preview, please contact us and we'd be happy to show you a draft.
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:
- upto 4096pxon the longest edge
- upto 16MPin total pixels
- upto 4 hoursin duration
- upto 4TBin size
Guides
... are coming soon!
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 uptoHighprofile atLevel 5.2(supports 4k@60fps). If you require a different profile, please contact us and we can activate it on an org-by-org basis. ↩
- 
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, and it's (one of the reasons) why digital TV resolutions are 1280x720, 1920x1080, 3840x2160, etc. ↩