Skip to main content

rivet/
lib.rs

1//! # rivet
2//!
3//! A modular, GPU-accelerated video transcoding library.
4//!
5//! `rivet` bundles two lower-level crates — [`codec`] (decode / encode /
6//! colorspace / probe) and [`container`] (demux / mux / CMAF / HLS) — behind
7//! a small, ergonomic facade for the common case: take an arbitrary input
8//! file and produce a single AV1 + Opus MP4.
9//!
10//! ## Output policy
11//!
12//! The output codec is **AV1** (video) + **Opus / AAC passthrough** (audio)
13//! muxed into **MP4**. This is a deliberate, royalty-clean target — see the
14//! project README. Input may be any container/codec the [`container`] and
15//! [`codec`] crates can demux + decode (H.264, HEVC, VP8/VP9, AV1, MPEG-2,
16//! MPEG-4, ProRes; MP4/MOV/MKV/WebM/MPEG-TS/AVI).
17//!
18//! ## Quick start
19//!
20//! ```no_run
21//! // Transcode a file on disk to an AV1/Opus MP4.
22//! let outcome = rivet::transcode_file("input.mkv", "output.mp4")?;
23//! println!("{} frames, {} bytes out", outcome.frames_processed, outcome.output_bytes.len());
24//!
25//! // Or inspect an input without transcoding it.
26//! let info = rivet::probe_file("input.mkv")?;
27//! println!("{}x{} {} @ {:.3} fps", info.width, info.height, info.video_codec, info.frame_rate);
28//! # Ok::<(), anyhow::Error>(())
29//! ```
30//!
31//! ## Lower-level access
32//!
33//! The component crates are re-exported for callers that need finer control
34//! than the facade offers (custom encoder configs, segment-level CMAF
35//! output, per-frame access, etc.):
36//!
37//! ```
38//! use rivet::codec::encode::EncoderConfig;
39//! use rivet::container::mux::Av1Mp4Muxer;
40//! ```
41
42pub mod cmaf_util;
43pub mod decode_pump;
44pub mod encoder_worker;
45pub mod frame_queue;
46pub mod gpu_pool;
47pub mod job;
48pub mod ladder;
49/// Batch manifest DSL (YAML/JSON), opt-in `batch` feature.
50#[cfg(feature = "batch")]
51pub mod manifest;
52pub mod multigpu;
53pub mod probe;
54pub mod progress;
55pub mod rung_scaler;
56/// HTTP transcode API (opt-in `server` feature).
57#[cfg(feature = "server")]
58pub mod server;
59pub mod settings;
60pub mod spec;
61#[cfg(feature = "thumbnail")]
62pub mod thumbnail;
63pub mod transcode;
64pub mod validate;
65
66// Re-export the component crates so downstream consumers can depend on a
67// single `rivet` crate and still reach the full lower-level API.
68pub use codec;
69pub use container;
70
71// Flatten the most common entry points to the crate root.
72pub use gpu_pool::{GpuLease, GpuPool};
73pub use job::{JobOutput, RungArtifact, RungOutput, run_job, run_job_blocking};
74pub use ladder::standard_ladder;
75pub use multigpu::{MultiGpuParams, RungManifest, detect_gpu_pool, run_multigpu_hls};
76pub use probe::{AudioStreamInfo, MediaInfo, probe_bytes, probe_file};
77pub use progress::{JobEvent, ProgressSink, RungProgress, RungStatus, channel_sink, fn_sink};
78#[cfg(feature = "batch")]
79pub use manifest::{
80    BatchReport, Format as ManifestFormat, JobOutcome, JobStatus, Manifest, run_manifest_file,
81};
82pub use settings::{Mode, TranscodeSettings};
83pub use spec::{
84    AudioPolicy, BitDepth, ColorPolicy, Container, EncodePolicy, GpuFamily, Muxer, OutputMode,
85    OutputSpec, Quality, Rung, VideoCodec,
86};
87pub use transcode::{AudioHandling, TranscodeOutcome, transcode_bytes, transcode_file};