1use std::fmt;
4
5use crate::types::Time;
6
7#[derive(Clone, Debug, PartialEq)]
9pub enum VideoFilter {
10 Scale {
12 width: u32,
14 height: u32,
16 },
17 Trim {
19 start: Time,
21 end: Option<Time>,
23 },
24 Custom(String),
26}
27
28impl VideoFilter {
29 pub fn to_filter_string(&self) -> String {
31 match self {
32 VideoFilter::Scale { width, height } => format!("scale={width}:{height}"),
33 VideoFilter::Trim { start, end } => match end {
34 Some(end) => format!("trim=start={start}:end={end}"),
35 None => format!("trim=start={start}"),
36 },
37 VideoFilter::Custom(raw) => raw.clone(),
38 }
39 }
40}
41
42impl fmt::Display for VideoFilter {
43 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
44 write!(f, "{}", self.to_filter_string())
45 }
46}