Skip to main content

Crate rivet

Crate rivet 

Source
Expand description

§rivet

A modular, GPU-accelerated video transcoding library.

rivet bundles two lower-level crates — codec (decode / encode / colorspace / probe) and container (demux / mux / CMAF / HLS) — behind a small, ergonomic facade for the common case: take an arbitrary input file and produce a single AV1 + Opus MP4.

§Output policy

The output codec is AV1 (video) + Opus / AAC passthrough (audio) muxed into MP4. This is a deliberate, royalty-clean target — see the project README. Input may be any container/codec the container and codec crates can demux + decode (H.264, HEVC, VP8/VP9, AV1, MPEG-2, MPEG-4, ProRes; MP4/MOV/MKV/WebM/MPEG-TS/AVI).

§Quick start

// Transcode a file on disk to an AV1/Opus MP4.
let outcome = rivet::transcode_file("input.mkv", "output.mp4")?;
println!("{} frames, {} bytes out", outcome.frames_processed, outcome.output_bytes.len());

// Or inspect an input without transcoding it.
let info = rivet::probe_file("input.mkv")?;
println!("{}x{} {} @ {:.3} fps", info.width, info.height, info.video_codec, info.frame_rate);

§Lower-level access

The component crates are re-exported for callers that need finer control than the facade offers (custom encoder configs, segment-level CMAF output, per-frame access, etc.):

use rivet::codec::encode::EncoderConfig;
use rivet::container::mux::Av1Mp4Muxer;

Re-exports§

pub use gpu_pool::GpuLease;
pub use gpu_pool::GpuPool;
pub use job::JobOutput;
pub use job::RungArtifact;
pub use job::RungOutput;
pub use job::run_job;
pub use job::run_job_blocking;
pub use ladder::standard_ladder;
pub use multigpu::MultiGpuParams;
pub use multigpu::RungManifest;
pub use multigpu::detect_gpu_pool;
pub use multigpu::run_multigpu_hls;
pub use probe::AudioStreamInfo;
pub use probe::MediaInfo;
pub use probe::probe_bytes;
pub use probe::probe_file;
pub use progress::JobEvent;
pub use progress::ProgressSink;
pub use progress::RungProgress;
pub use progress::RungStatus;
pub use progress::channel_sink;
pub use progress::fn_sink;
pub use settings::Mode;
pub use settings::TranscodeSettings;
pub use spec::AudioPolicy;
pub use spec::BitDepth;
pub use spec::ColorPolicy;
pub use spec::Container;
pub use spec::EncodePolicy;
pub use spec::GpuFamily;
pub use spec::Muxer;
pub use spec::OutputMode;
pub use spec::OutputSpec;
pub use spec::Quality;
pub use spec::Rung;
pub use spec::VideoCodec;
pub use transcode::AudioHandling;
pub use transcode::TranscodeOutcome;
pub use transcode::transcode_bytes;
pub use transcode::transcode_file;
pub use codec;
pub use container;

Modules§

cmaf_util
Shared CMAF/HLS helpers used by the job engine and the multi-GPU orchestrator: segment-boundary flushing, per-rung contribution merging, bandwidth measurement, and AV1 codec-string extraction.
decode_pump
Shared source decode pump.
encoder_worker
Per-segment encoder worker: pop a chunk → encode K frames → emit one CMAF segment file → repeat.
frame_queue
Per-rung segment chunk queue connecting the decode pump to N encoder workers.
gpu_pool
Process-wide GPU reservation pool.
job
The transcode job engine.
ladder
ABR ladder computation — derive a sensible set of Rungs from a source resolution.
multigpu
Multi-GPU reactive variant phase — the rung benefit.
probe
Inspect an input without transcoding it.
progress
Job progress reporting.
rung_scaler
Per-rung scaler task: consume raw normalized source frames from the shared decode pump, scale to rung dims, group K frames into a SegmentChunk, push to the rung’s SegmentChunkQueue.
settings
One canonical definition of the transcode “knobs”, shared by every front-end — the CLI (transcode / pipe), the HTTP API, and the IPC socket. Each surface parses its own syntax (clap flags / JSON / query string / key=value) into a TranscodeSettings, then calls TranscodeSettings::into_spec. Add a new option once here (a field + a line in into_spec + a parse_* arm) and every surface picks it up, instead of maintaining three copies of the spec-building logic.
spec
Output specification — how a job should be transcoded.
transcode
Single-file transcode: arbitrary input → AV1 + audio MP4.
validate
Optional input-policy validation.