Skip to main content

Codec

Enum Codec 

Source
#[repr(u32)]
pub enum Codec { Jpeg = 0, H264 = 1, Vp8 = 2, Vp9 = 3, Av1 = 4, H265 = 5, }
Expand description

The picture codec of a capture session, and of a virtual-camera uplink. Jpeg is the striped still-image mode; the rest are video codecs, which stream as whole frames except H.264, whose software path may also stripe. The discriminants are the codec ids the Python API speaks (VirtualCamera.CODEC_*) and the video wire ids.

Variants§

§

Jpeg = 0

§

H264 = 1

§

Vp8 = 2

§

Vp9 = 3

§

Av1 = 4

§

H265 = 5

Implementations§

Source§

impl Codec

Source

pub const VIDEO: [Codec; 5]

The video codecs, in wire-id order.

Source

pub const fn id(self) -> u32

The codec’s numeric id, as the Python API and the video wire carry it.

Source

pub fn from_id(id: u32) -> Option<Codec>

The codec a numeric id names.

Source

pub fn parse(name: &str) -> Option<Codec>

The codec a settings name selects; None for a name no backend serves.

Source

pub fn name(self) -> &'static str

The settings and log name of the codec.

Source

pub fn display(self) -> &'static str

The name a stream line prints.

Source

pub fn is_video(self) -> bool

Whether the session is a video stream rather than striped stills.

Source

pub fn stripes(self) -> bool

Whether a frame of this codec may be cut into independently encoded stripes: the still-image mode always is, H.264 is on its software path, and every other codec streams whole frames.

Source

pub fn wire_id(self) -> u8

The codec’s identity in the high nibble of the video type byte: its id.

Source

pub fn from_wire_id(id: u8) -> Option<Codec>

The video codec a wire id names.

Source

pub fn data_type(self) -> i32

The codec tag the Python StripeFrame carries: the codec id.

Source

pub fn is_inter_coded(self) -> bool

Whether frames depend on earlier ones, so a dropped frame forces a wait for a key frame.

Source

pub fn fullcolor(self) -> bool

Whether the codec can carry 4:4:4 chroma at all (H.264 High 4:4:4, H.265 RExt, VP9 profile 1); whether a given backend does is negotiated by that backend.

Source

pub fn high_bit_depth(self) -> bool

Whether the codec has a 10-bit profile a session here can ask for (H.265 Main 10 and its 4:4:4, VP9 profiles 2 and 3, AV1); whether a given backend does is negotiated by that backend.

Source

pub fn keyframes_self_contained(self) -> bool

Whether a forced key frame of this codec repeats the stream’s parameter sets, so a joining decoder can start there. Every backend is configured to, so the answer is the same for all of them.

Source

pub fn quantizer_max(self) -> u32

The top of the codec’s quantizer domain: H.26x QP, the VP8 quantizer index, or the VP9 / AV1 base_q_idx. The value a backend programs never exceeds it.

Source

pub fn quantizer(self, crf: i32) -> u32

The quantizer, in this codec’s own domain, that a session quality index (video_crf, on the H.26x QP scale) selects.

H.26x takes the index as its QP. The VP8, VP9, and AV1 quantizer indices come from tables measured on the software encoders against libx264 (ultrafast, zerolatency, four threads) at the same index, every encoder at the settings pixelflux gives it — VP8 at libvpx speed 16, VP9 at speed 8 with screen tuning, AV1 at SVT-AV1 preset 11 in its real-time mode — interpolated in between. An AV1 point is the quantizer whose SSIM matches on a scrolling text desktop. A VP8 or VP9 point is the one whose PSNR matches, the finest of a text desktop held still, the same scrolled, and a gradient wallpaper, which agree within two libvpx levels for VP9; VP8 reaches 43 dB at its finest, so below index 25 it has nothing left to match. Each table ends at the codec’s maximum quantizer at index 51, since past its last matched point the encoder cannot degrade as far as x264 does and there is nothing left to match. A hardware session reads hardware_quantizer. An AV1 index of zero is lossless, so its floor is one; the SVT-AV1 session floors its level at ten, below which its real-time mode miscodes.

Source

pub fn quantizer_bound(self, qp: i32) -> u32

The quantizer a CBR QP clamp (video_min_qp / video_max_qp, on the H.26x scale) becomes in this codec’s domain; zero stays zero, meaning “the encoder’s default”.

Source

pub fn hardware_quantizer(self, hw: Hardware, crf: i32) -> u32

quantizer for a hardware session, matched to libx264 the same way. H.264 is measured on NVENC (Pascal and Ada) and on AMD’s VA-API, which agree within a step, each coding a quantizer about three finer than the index to match x264; AMD’s VA-API H.265 follows the same curve within a step, where NVENC’s H.265 is within two steps of the index from 22 up and keeps it. Intel’s VA-API H.265 matches x264 on a still frame at that curve but refines a moving picture well past it for fewer bytes (Arc and Alder Lake-N), so it reads one two steps coarser from index 25 up; below 20 its still frames of text fall 3 to 4 dB short of x264’s at that curve, so there it reads one finer. AV1 has a curve per backend: NVENC’s is measured on Ada, and VA-API’s on Intel (Arc) with the in-loop filters its constant-quantizer frames carry, on a text desktop and a gradient wallpaper, taking the finer match of the two. VA-API’s VP9 is matched the same way on Intel (Arc), finer than libvpx at the same index on text. VP8 keeps the software table. NVENC refuses an AV1 index of zero, so the floor stays one.

Source

pub fn hardware_quantizer_bound(self, hw: Hardware, qp: i32) -> u32

quantizer_bound for a hardware session.

Source

pub fn quality_index(self, q: u32) -> u32

The session quality index whose quantizer (quantizer) is nearest q, a quantizer of this codec’s domain: what a rate-controlled frame’s quantizer amounts to on the H.26x scale the quality settings use.

Source

pub fn hardware_quality_index(self, hw: Hardware, q: u32) -> u32

quality_index for a hardware session.

Trait Implementations§

Source§

impl Clone for Codec

Source§

fn clone(&self) -> Codec

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 Copy for Codec

Source§

impl Debug for Codec

Source§

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

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

impl Eq for Codec

Source§

impl Hash for Codec

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Codec

Source§

fn eq(&self, other: &Codec) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Codec

Auto Trait Implementations§

§

impl Freeze for Codec

§

impl RefUnwindSafe for Codec

§

impl Send for Codec

§

impl Sync for Codec

§

impl Unpin for Codec

§

impl UnsafeUnpin for Codec

§

impl UnwindSafe for Codec

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> Ungil for T
where T: Send,

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more