Skip to main content

CodecCapabilities

Struct CodecCapabilities 

Source
#[non_exhaustive]
pub struct CodecCapabilities {
Show 17 fields pub decode: bool, pub encode: bool, pub media_type: MediaType, pub intra_only: bool, pub lossy: bool, pub lossless: bool, pub hardware_accelerated: bool, pub implementation: String, pub max_width: Option<u32>, pub max_height: Option<u32>, pub max_bitrate: Option<u64>, pub max_sample_rate: Option<u32>, pub max_channels: Option<u16>, pub priority: i32, pub accepted_pixel_formats: Vec<PixelFormat>, pub accepted_sample_rates: Vec<u32>, pub accepted_sample_formats: Vec<SampleFormat>,
}
Expand description

What an implementation can do plus how it ranks vs alternatives.

#[non_exhaustive]: build it with audio, video or subtitle and the with_* builders, then read the public fields. Fields are added over time (0.1.38 added the accepted sample rates / formats) and a struct literal in a downstream crate would stop compiling each time.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§decode: bool

Decoding supported by this implementation.

§encode: bool

Encoding supported by this implementation.

§media_type: MediaType

Media type this implementation handles (audio, video, …).

§intra_only: bool

Every coded unit is independently decodable (no inter-frame prediction).

§lossy: bool

Supports lossy compression.

§lossless: bool

Supports lossless compression. lossy and lossless may both be set for codecs that offer both modes.

§hardware_accelerated: bool

Hardware-accelerated implementation (VAAPI/NVENC/QSV/VideoToolbox/…).

§implementation: String

Short identifier for this implementation, e.g. “flac_sw”, “h264_qsv”.

§max_width: Option<u32>

Restrictions — None means “no constraint”.

§max_height: Option<u32>

Maximum supported frame height in pixels; None = unconstrained.

§max_bitrate: Option<u64>

Maximum supported bit rate in bits per second; None = unconstrained.

§max_sample_rate: Option<u32>

Maximum supported audio sample rate in Hz; None = unconstrained.

§max_channels: Option<u16>

Maximum supported audio channel count; None = unconstrained.

§priority: i32

Lower numbers are preferred. HW impls should be ~10, SW impls ~100.

§accepted_pixel_formats: Vec<PixelFormat>

Pixel formats this implementation accepts (video only). An empty Vec means “any format” — resolution won’t filter on it. When populated, the registry can skip impls whose accepted set does not include the format requested by the caller.

§accepted_sample_rates: Vec<u32>

Audio sample rates (Hz) this implementation accepts as encoder input (audio only). An empty Vec means “any rate”. When populated, a pipeline feeding the encoder is expected to resample a stream whose rate is not listed to one of these rates (the listed order is not a preference — consumers pick the closest rate that does not discard bandwidth).

§accepted_sample_formats: Vec<SampleFormat>

Audio sample formats this implementation accepts as encoder input (audio only). An empty Vec means “any format”. When populated, the first entry is the preferred conversion target for a stream whose format is not listed.

Implementations§

Source§

impl CodecCapabilities

Source

pub fn audio(implementation: impl Into<String>) -> Self

Construct a software audio decoder/encoder capability set with sensible defaults — adjust fields after creation.

Source

pub fn video(implementation: impl Into<String>) -> Self

Construct a software video decoder/encoder capability set with sensible defaults — adjust fields after creation.

Source

pub fn subtitle(implementation: impl Into<String>) -> Self

Construct a software subtitle decoder/encoder capability set with sensible defaults (intra-only, lossless) — adjust with the with_* builders.

Source

pub fn with_media_type(self, media_type: MediaType) -> Self

Override the media type (for capability sets built from the closest constructor, e.g. data or attachment streams).

Source

pub fn flag_string(&self) -> String

6-character capability flag string (see the module docs for the column layout). Useful for oxideav list-style output.

Source

pub fn with_decode(self) -> Self

Mark this implementation as supporting decode.

Source

pub fn with_encode(self) -> Self

Mark this implementation as supporting encode.

Source

pub fn with_intra_only(self, v: bool) -> Self

Set the intra-frame-only flag.

Source

pub fn with_lossy(self, v: bool) -> Self

Set the lossy-compression flag.

Source

pub fn with_lossless(self, v: bool) -> Self

Set the lossless-compression flag.

Source

pub fn with_hardware(self, v: bool) -> Self

Set the hardware-accelerated flag.

Source

pub fn with_priority(self, p: i32) -> Self

Set the registry ranking priority (lower is preferred; HW ~10, SW ~100).

Source

pub fn with_max_size(self, w: u32, h: u32) -> Self

Constrain the maximum frame size to w × h pixels.

Source

pub fn with_max_bitrate(self, br: u64) -> Self

Constrain the maximum bit rate (bits per second).

Source

pub fn with_max_sample_rate(self, sr: u32) -> Self

Constrain the maximum audio sample rate (Hz).

Source

pub fn with_max_channels(self, ch: u16) -> Self

Constrain the maximum audio channel count.

Source

pub fn with_pixel_format(self, fmt: PixelFormat) -> Self

Add one accepted pixel format. Appends — call multiple times to list several.

Source

pub fn with_pixel_formats(self, fmts: Vec<PixelFormat>) -> Self

Replace the accepted pixel-format set wholesale.

Source

pub fn with_sample_rates(self, rates: Vec<u32>) -> Self

Replace the accepted encoder-input sample-rate set wholesale (see Self::accepted_sample_rates).

Source

pub fn with_sample_formats(self, fmts: Vec<SampleFormat>) -> Self

Replace the accepted encoder-input sample-format set wholesale (see Self::accepted_sample_formats; the first entry is the preferred conversion target).

Source

pub fn pick_sample_rate(&self, rate: u32) -> u32

Pick the encoder-input sample rate for a stream at rate Hz: rate itself when it is accepted (or every rate is), otherwise the smallest accepted rate above it (no bandwidth is lost), and failing that the largest accepted rate.

Source§

impl CodecCapabilities

Source

pub fn fits_params(&self, p: &CodecParameters, for_encode: bool) -> bool

Whether this implementation’s max-* restrictions are compatible with the requested codec parameters. for_encode is reserved for restrictions that apply asymmetrically. Used by the registry’s make_decoder / make_encoder walker and by out-of-tree selection layers (e.g. oxideav-pipeline’s CodecPreferences filter).

Trait Implementations§

Source§

impl Clone for CodecCapabilities

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CodecCapabilities

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for CodecCapabilities

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.