Expand description
Realtime AV1 and VP9 video encoders and decoders behind one interface (VideoEncoder,
VideoDecoder).
-
VP9 on libvpx (
Vp9Encoder,Vp9Decoder; featurelibvpx): realtime mode with three temporal layers (L1T3, pattern 0-2-1-2). -
AV1: SVT-AV1 encodes (
Av1Encoder; featuresvt-av1) in its low-delay realtime mode with the same three temporal layers; dav1d decodes (Av1Decoder; featuredav1d). -
Hardware encoders (
open_hardware_encoder; featuresnvenc,vaapi,amf,qsv): NVENC, VA-API, AMF and Quick Sync on Windows and Linux, usable only where the GPU driver loads. -
Detection (
detect_encoders) tells which hardware encoders really work on this machine and why the others do not;open_best_encoderopens the first one that works and ends with software;measure_av1tells whether software AV1 runs in real time here.
The crate stores nothing and prints nothing: results come back as values, diagnostics go to
the log crate.
Every feature is on by default; a codec whose feature is off is not part of the build. The
plain values TEMPORAL_LAYERS, AV1_TEMPORAL_LAYERS, Av1Options, vp9_threads
and av1_cpu_supported exist in every build, also without any feature.
Dropping every frame of the top layer halves the frame rate, dropping the top two quarters
it, and the remaining frames still decode. Each EncodedFrame carries its layer id so a
sender can thin out the stream per viewer without re-encoding. Resolution steps are a runtime
reconfiguration of the same encoder.
Frames are I420 in one tightly packed buffer (Y, then U, then V; chroma planes are half the size, rounded up).
Re-exports§
pub use detect::EncoderReport;pub use detect::EncoderStatus;pub use detect::detect_encoder;pub use detect::detect_encoders;pub use fallback::EncoderKind;pub use fallback::default_order;pub use fallback::open_best_encoder;pub use fallback::open_software_decoder;pub use selftest::DEFAULT_PASS_PERCENT;pub use selftest::SelftestResult;pub use selftest::measure_av1;
Modules§
- convert
- Colour conversion between BGRA or RGBA pictures and I420.
- detect
- Detection of the hardware encoders that work on this machine, with a reason for each one that does not.
- fallback
- Fallback from one encoder to the next, in an order the caller can replace.
- selftest
- Speed self-test that tells whether this machine is fast enough for software AV1 encoding.
Structs§
- Av1Decoder
- AV1 decoder on dav1d.
- Av1Encoder
- Realtime AV1 encoder on SVT-AV1 (low delay, CBR) with
AV1_TEMPORAL_LAYERStemporal layers. - Av1Options
- Software AV1 options that only exist for this encoder.
- Encoded
Frame - One compressed frame (VP9 or AV1), ready to send.
- Encoder
Config - What an encoder is opened with.
- I420
Frame - One I420 picture: Y plane, then U, then V, without row padding.
- Vp9Decoder
- VP9 decoder on libvpx.
- Vp9Encoder
- Realtime VP9 encoder with L1T3 temporal layers (or the number the configuration asks for).
Enums§
- Codec
- The video formats this crate encodes and decodes.
- Error
- What can go wrong in this crate.
- Hardware
Encoder - The hardware encoders this crate knows, one per vendor interface.
Constants§
- AV1_
TEMPORAL_ LAYERS - Temporal layers (pattern 0-2-1-2). SVT-AV1’s low-delay CBR mode allows at most three (hierarchical levels 0–2), so unlike VP9 and the hardware encoders it has no fourth layer at 60 fps; software AV1 is rarely fast enough for 60 fps anyway.
- MAX_
DECODED_ HEIGHT - Tallest picture a decoder hands out, see
MAX_DECODED_WIDTH. - MAX_
DECODED_ WIDTH - Widest picture a decoder hands out: 8K UHD.
- TEMPORAL_
LAYERS - Number of VP9 temporal layers (L1T3) unless the configuration asks for fewer; also the most the encoder produces. Layer ids run 0..TEMPORAL_LAYERS.
Traits§
- Video
Decoder - Decodes one compressed frame at a time into I420.
- Video
Encoder - A realtime encoder with temporal layers. Every call is synchronous: a frame passed to
Self::encodecomes back compressed from the same call.
Functions§
- av1_
cpu_ supported - SVT-AV1 4.2’s SSSE3 code, which it picks on x86 CPUs without AVX2, reads a reference block
with an aligned load that is not always aligned (
svt_aom_sub_pixel_variance16xh_ssse3), so the encoder kills the whole process with a general protection fault. Such CPUs are also far too slow for real-time AV1, so callers should use VP9 there instead. Callers check this before opening an encoder;Av1Encoder::newrefuses such CPUs as a safety net. - open_
hardware_ encoder - Opens
encoderforcodec, or fails withError::HardwareUnavailablewhen this build, system or GPU can’t provide it. - vp9_
threads - The libvpx thread count a software VP9 encoder is configured with unless the configuration names one.
Type Aliases§
- Result
- The result type of this crate.