Expand description
A real-time VP8 video encoder in pure, safe Rust.
It turns I420 pictures into raw VP8 frames (RFC 6386) for live video: camera and screen sharing over WebRTC. No look-ahead and no reordering: one frame in, at most one frame out.
- Rate control to a target bitrate, changeable at any time with
Encoder::set_rates; frames are skipped when the stream runs far over budget. - Keyframes on request (
Encoder::request_keyframeor theforce_keyframeflag), for PLI and FIR. - Optional temporal layers (L1T2, L1T3) in the usual WebRTC pattern.
- Simulcast: run one encoder per layer, each at its own size;
scale_i420makes the smaller pictures.
Every frame’s probability updates apply to that frame only, so a lost or dropped frame never leaves a receiver with the wrong probabilities.
use vp8_encoder::{Encoder, EncoderConfig, Picture};
let mut enc = Encoder::new(EncoderConfig::new(1280, 720, 30, 2_000_000)).unwrap();
let i420 = vec![128u8; 1280 * 720 * 3 / 2];
let picture = Picture::from_i420(&i420, 1280, 720).unwrap();
if let Some(frame) = enc.encode(&picture, false).unwrap() {
// frame.data is one raw VP8 frame, ready for an RTP packetiser.
let _ = (frame.keyframe, frame.temporal_id, frame.layer_sync);
}See PROVENANCE.md for how this crate was written.
Structs§
- Encoded
Frame - One encoded frame.
- Encoder
- A real-time VP8 encoder for one stream (one simulcast layer).
- Encoder
Config - Encoder settings.
- Picture
- A borrowed planar YUV 4:2:0 (I420) picture.
Enums§
- Encode
Error - Why a frame could not be encoded.
- Temporal
Layers - Temporal layering.
Functions§
- scale_
i420 - Scales
srctowidthxheightand appends it tooutas packed I420. Downscaling averages the source area under each output pixel; upscaling interpolates bilinearly.