Skip to main content

ff_encode/video/codec_options/
svt_av1.rs

1//! SVT-AV1 (libsvtav1) per-codec encoding options.
2
3/// SVT-AV1 (libsvtav1) per-codec options.
4///
5/// **Note**: Requires an FFmpeg build with `--enable-libsvtav1` (LGPL).
6/// `build()` returns [`EncodeError::EncoderUnavailable`](crate::EncodeError::EncoderUnavailable)
7/// when libsvtav1 is absent from the FFmpeg build.
8#[derive(Debug, Clone)]
9pub struct SvtAv1Options {
10    /// Encoder preset: 0 = best quality / slowest, 13 = fastest / lowest quality.
11    pub preset: u8,
12    /// Log2 number of tile rows (0–6).
13    pub tile_rows: u8,
14    /// Log2 number of tile columns (0–6).
15    pub tile_cols: u8,
16    /// Raw SVT-AV1 params string passed verbatim (e.g. `"fast-decode=1:hdr=0"`).
17    ///
18    /// `None` leaves the encoder default. Invalid values are logged as a warning
19    /// and skipped — `build()` never fails due to an unsupported parameter.
20    pub svtav1_params: Option<String>,
21}
22
23impl Default for SvtAv1Options {
24    fn default() -> Self {
25        Self {
26            preset: 8,
27            tile_rows: 0,
28            tile_cols: 0,
29            svtav1_params: None,
30        }
31    }
32}
33
34#[cfg(test)]
35mod tests {
36    use super::*;
37
38    #[test]
39    fn svtav1_options_default_should_have_preset_8() {
40        let opts = SvtAv1Options::default();
41        assert_eq!(opts.preset, 8);
42        assert_eq!(opts.tile_rows, 0);
43        assert_eq!(opts.tile_cols, 0);
44        assert!(opts.svtav1_params.is_none());
45    }
46}