use codec::frame::VideoCodec;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum VideoCodecPolicy {
#[default]
Av1,
H264,
H265,
}
impl VideoCodecPolicy {
pub fn codec(self) -> VideoCodec {
match self {
VideoCodecPolicy::Av1 => VideoCodec::Av1,
VideoCodecPolicy::H264 => VideoCodec::H264,
VideoCodecPolicy::H265 => VideoCodec::H265,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum AudioCodecPolicy {
#[default]
Auto,
ForceOpus,
Drop,
}
#[deprecated(since = "0.1.5", note = "renamed to AudioCodecPolicy")]
pub type AudioPolicy = AudioCodecPolicy;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Container {
#[default]
Mp4,
Cmaf,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Muxer {
#[default]
Mp4File,
CmafHls,
}
#[derive(Debug, Clone, PartialEq)]
pub enum OutputMode {
SingleFile,
Hls { segment_seconds: f32 },
}
impl Default for OutputMode {
fn default() -> Self {
OutputMode::SingleFile
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum DecodePolicy {
#[default]
Auto,
SpecificGpu(u32),
FastestGpu,
}
impl DecodePolicy {
pub fn gpu_index(self) -> Option<u32> {
match self {
DecodePolicy::SpecificGpu(i) => Some(i),
DecodePolicy::Auto | DecodePolicy::FastestGpu => None,
}
}
pub fn is_fastest(self) -> bool {
matches!(self, DecodePolicy::FastestGpu)
}
}
impl std::str::FromStr for DecodePolicy {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.trim().to_ascii_lowercase().as_str() {
"" | "auto" => Ok(DecodePolicy::Auto),
"fastest" => Ok(DecodePolicy::FastestGpu),
other => other.parse::<u32>().map(DecodePolicy::SpecificGpu).map_err(|_| {
format!("decode-gpu must be 'auto', 'fastest', or a GPU index; got '{other}'")
}),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum EncodePolicy {
#[default]
AllGpus,
SingleGpu(Option<u32>),
Family(GpuFamily),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum GpuFamily {
Nvidia,
Amd,
Intel,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum ChunkSeamMode {
#[default]
Parallel,
ParallelConstQp,
Serial,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum ColorPolicy {
#[default]
TonemapToSdr,
Passthrough,
Hdr10,
Hlg,
}
impl ColorPolicy {
pub fn tonemaps(self) -> bool {
matches!(self, ColorPolicy::TonemapToSdr)
}
pub fn is_hdr(self) -> bool {
matches!(self, ColorPolicy::Hdr10 | ColorPolicy::Hlg)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum BitDepth {
#[default]
Auto,
EightBit,
TenBit,
}