Encoding Guide
Backed by FFmpeg, Remotion allows you to configure a variety of encoding settings. The goal of this page is to help you navigate through the settings and to help you choose the right one.
Choosing a codec
Remotion supports 5 video codecs: h264
(default), h265
, vp8
, vp9
and prores
. While H264 will work well in most cases, sometimes it's worth going for a different codec. Refer to the table below to see the advantages and drawbacks of each codec.
Codec | File extension | File size | Encoding time | Browser compatibility |
---|---|---|---|---|
H.264 also known as MPEG-4 | .mp4, .mov or .mkv | Medium | Very fast | Very good |
H.265 also known as HEVC | .mp4 or .hevc | Medium | Fast | Very poor |
VP8 | .webm | Small | Slow | Okay |
VP9 | .webm | Very small | Very slow | Okay |
ProRes | .mov | Large | Fast | None |
Click on a browser compatibility link to see exactly which browsers are supported on caniuse.com.
You can set a config using Config.setCodec()
in the config file or the --codec
CLI flag.
Controlling quality using the CRF setting
Applies only to h264
, h265
, vp8
and vp9
.
No matter which codec you end up using, there's always a tradeoff between file size and video quality. You can control it by setting the so called CRF (Constant Rate Factor). The lower the number, the better the quality, the higher the number, the smaller the file is – of course at the cost of quality.
Be cautious: Every codec has it's own range of acceptable values and a different default. So while 23
will look very good on a H264 video, it will look terrible on a WebM video. Use this chart to determine which CRF value to use:
Changelog
- Since version 2.1.3, Remotion doesn't allow the CRF to be set to
0
anymore because of the issues it causes on macOS/iOS and possible other scenarios. Set the CRF to 1 or higher.
Codec | Minimum - Best quality | Maximum - Best compression | Default |
---|---|---|---|
H264 | 1 | 51 | 18 |
H265 | 0 | 51 | 23 |
VP8 | 4 | 63 | 9 |
VP9 | 0 | 63 | 28 |
You can set a CRF in the config file using the Config.setCrf()
function or use the --crf
command line flag.
Controlling quality using ProRes profile
Applies only to prores
codec.
For ProRes, there is no CRF option, but there are profiles which you can set using the --prores-profile
flag or the setProResProfile
config file option.
Value | FFmpeg setting | Bitrate | Supports alpha channel |
---|---|---|---|
"proxy" | 0 | ~45Mbps | No |
"light" | 1 | ~102Mbps | No |
"standard" (default) | 2 | ~147Mbps | No |
"hq" | 3 | ~220Mbps | No |
"4444" | 4 | ~330Mbps | Yes |
"4444-xq" | 4 | ~500Mbps | Yes |
Higher bitrate means higher quality and higher file size.
Audio-only export
You can pass mp3
, wav
or aac
as a codec. If you do it, an audio file will be output in the corresponding format. Quality settings will be ignored.
GIFs
You can also render your video as a GIF.
Audio codec
available from v3.3.42
Using the --audio-codec
flag, you can set the format of the audio that is embedded in the video. Not all codec and audio codec combinations are supported and certain combinations require a certain file extension and container format.
The container format will be automatically derived based on the file extension.
Video codec | Default | Supported audio codecs | Possible file extensions |
---|---|---|---|
h264 | ✅ | aac | .mp4 (default), .mkv , .mov |
pcm-16 | .mkv (default), .mov | ||
mp3 | .mp4 (default), .mkv , .mov | ||
h264-ts | pcm-16 | .ts (default) | |
✅ | aac | .ts (default) | |
aac | ✅ | aac | .aac (default), .3gp , .m4a , .m4b , .mpg , .mpeg |
pcm-16 | .wav (default) | ||
h265 | ✅ | aac | .mp4 (default), .mkv , .hevc |
pcm-16 | .mkv (default) | ||
mp3 | ✅ | mp3 | .mp3 (default) |
pcm-16 | .wav (default) | ||
prores | * | aac | .mov (default), .mkv , .mxf |
✅ | pcm-16 | .mov (default), .mkv , .mxf | |
vp8 | ✅ | opus | .webm (default) |
pcm-16 | .mkv (default) | ||
vp9 | ✅ | opus | .webm (default) |
pcm-16 | .mkv (default) | ||
wav | ✅ | pcm-16 | .wav (default) |
GIFs don't support audio.
* Note: In versions before v4.0.0
the default audio codec for ProRes
was aac
. Now it's pcm-16
.
File extensions
Specifying a file extension when rendering media will determine the default codec. You may override the codec using --codec
as long as the combination is supported in the table above.
File extension | Default codec |
---|---|
.3gp | aac |
.aac | aac |
.gif | gif |
.hevc | h265 |
.m4a | aac |
.m4b | aac |
.mkv | h264-mkv |
.mov | prores |
.mp3 | mp3 |
.mp4 | h264 |
.mpeg | aac |
.mpg | aac |
.mxf | prores |
.wav | wav |
.webm | vp8 |
.ts | h264-ts |
What other settings do you need?
Which of the dozens of options that FFmpeg supports would you like to see exposed in Remotion? Let us know by opening an issue on our issue tracker!