| 5 | | `libaom-av1` is the AOMedia video encoder for [https://en.wikipedia.org/wiki/AV1 AV1], an open source & royalty-free video codec. `libaom-av1` can save about 30% bitrate compared to VP9 and H.265 / HEVC, and about 50% over H.264, while retaining the same visual quality. |
| | 10 | [https://en.wikipedia.org/wiki/AV1 AV1] is an open source & royalty-free video codec developed by the [https://en.wikipedia.org/wiki/Alliance_for_Open_Media Alliance for Open Media] (AOMedia), a non-profit industry consortium. Depending on the use case, AV1 can achieve about 30% higher compression efficiency than VP9, and about 50% higher efficiency than H.264. |
| | 11 | |
| | 12 | There are currently three AV1 encoders supported by FFmpeg: libaom (invoked with `libaom-av1` in FFmpeg), SVT-AV1 (`libsvtav1`), and rav1e (`librav1e`). This guide currently focuses on libaom and SVT-AV1. |
| | 13 | |
| | 14 | = libaom = |
| | 15 | |
| | 16 | libaom (`libaom-av1`) is the reference encoder for the AV1 format. It was also used for research during the development of AV1. `libaom` is based on `libvpx` and thus shares many of its characteristics in terms of features, performance, and usage. |
| 120 | | The range of options are similar to that of libaom (aomenc). It is supposed to be faster than libaom while having comparable quality. |
| | 131 | To enable support, FFmpeg needs to be built with `--enable-libsvtav1`. For options available in your specific build of FFmpeg, see `ffmpeg -help encoder=libasvav1`. See also [https://www.ffmpeg.org/ffmpeg-all.html#libsvtav1 FFmpeg documentation] and the [https://gitlab.com/AOMediaCodec/SVT-AV1/-/blob/master/Docs/svt-av1_encoder_user_guide.md upstream encoder user guide]. |
| | 132 | |
| | 133 | As of FFmpeg 5.0, relatively few encoder options are supported by FFmpeg. However, since 2022-02-24, the FFmpeg git has supported `-svtav1-params`, which was introduced in SVT-AV1 0.9.1 for passing encoder options. |
| | 134 | |
| | 135 | CRF is the default rate control method, and while VBR and CBR are also available, as of SVT-AV1 0.9.1 they're a work-in-progress and only recommended for "demos, experimentation, and further development uses" as per encoder output. |
| | 136 | |
| | 137 | == CRF == |
| | 138 | |
| | 139 | Much like CRF in x264 and x265, this rate control method tries to ensure that every frame gets the number of bits it deserves to achieve a certain (perceptual) quality level. |
| | 140 | |
| | 141 | For example: |
| | 142 | |
| | 143 | {{{ |
| | 144 | ffmpeg -i input.mp4 -c:v libsvtav1 -crf 35 svtav1_test.mp4 |
| | 145 | }}} |
| | 146 | |
| | 147 | Note that the `-crf` option is only supported in FFmpeg git builds since 2022-02-24. Prior to this, the CRF value is set with `-qp`. |
| | 148 | |
| | 149 | The valid CRF value range is 0-63, with the default being 50. Lower values correspond to higher quality and greater file size. Lossless encoding is currently [https://gitlab.com/AOMediaCodec/SVT-AV1/-/issues/1636 not supported.] |
| | 150 | |
| | 151 | == Presets and tunes == |
| | 152 | |
| | 153 | The trade-off between encoding speed and compression efficiency is managed with the `-preset` option. Since SVT-AV1 0.9.0, supported presets range from 0 to 13, with higher numbers providing a higher encoding speed. |
| | 154 | |
| | 155 | Note that preset 13 is only meant for debugging and running fast convex-hull encoding. In versions prior to 0.9.0, valid presets are 0 to 8. |
| | 156 | |
| | 157 | As an example, this command encodes a video using preset 8 and a CRF of 35 while copying the audio: |
| | 158 | |
| | 159 | {{{ |
| | 160 | ffmpeg -i input.mp4 -c:a copy -c:v libsvtav1 -preset 8 -crf 35 svtav1_test.mp4 |
| | 161 | }}} |
| | 162 | |
| | 163 | Since SVT-AV1 0.9.1, the encoder also supports tuning for visual quality (sharpness). This is invoked with `-svtavt-params tune=0`. The default value is 1, which tunes the encoder for PSNR. |
| | 164 | |
| | 165 | Also supported since 0.9.1 is tuning the encoder to produce bitstreams that are faster (less CPU intensive) to decode, similar to the `fastdecode` tune in x264 and x265. This feature is invoked with `-svtav1-params fast-decode=X`, with X being an integer from 1 to 3. Higher numbers result in easier-to-decode video. |
| | 166 | |
| | 167 | Decoder tuning is only supported for presets from 5 to 10. The level of decoder tuning supported varies by preset. |
| | 168 | |
| | 169 | == Keyframe placement == |
| | 170 | |
| | 171 | By default, SVT-AV1's keyframe interval 2-3 seconds, which is quite short for most use cases. Consider changing this up to 10 seconds with the `-g` option; `-g 240` for 24 fps content, `-g 300` for 30 fps, etc. |
| | 172 | |
| | 173 | Note that as of SVT-AV1 0.9.1, scene change detection is not considered to be in an optimal state and is disabled by default. This means that the default behavior is to place keyframes at set intervals instead of at scene changes and other optimal locations. Scene change detection can be turned on with `-sc_detection 1` or via the svtav1-params option `scd=1`. |
| | 174 | |
| | 175 | == Film grain synthesis == |
| | 176 | |
| | 177 | SVT-AV1 supports film grain synthesis, an AV1 feature for preserving the look of grainy video while spending very little bitrate to do so. The grain is removed from the image with denoising, its look is approximated and synthesized, and then added on top of the video at decode-time as a filter. |
| | 178 | |
| | 179 | The film grain synthesis feature is invoked with `-svtav1-params film-grain=X`, where X is an integer from 1 to 50. Higher numbers correspond to higher levels of denoising for the grain synthesis process and thus a higher amount of grain. |