ff_stream/lib.rs
1//! # ff-stream
2//!
3//! HLS and DASH adaptive streaming output - the Rust way.
4//!
5//! This crate provides segmented HLS and DASH output along with ABR (Adaptive
6//! Bitrate) ladder generation. It exposes a safe, ergonomic Builder API and
7//! completely hides `FFmpeg` muxer internals.
8//!
9//! ## Features
10//!
11//! - **HLS Output**: Segmented HLS with configurable segment duration and keyframe interval
12//! - **DASH Output**: Segmented DASH with configurable segment duration
13//! - **ABR Ladder**: Multi-rendition HLS / DASH from a single input in one call
14//! - **Builder Pattern**: Consuming builders with validation in `build()`
15//!
16//! ## Usage
17//!
18//! ### HLS Output
19//!
20//! ```ignore
21//! use ff_stream::HlsOutput;
22//! use std::time::Duration;
23//!
24//! HlsOutput::new("/var/www/hls")
25//! .input("source.mp4")
26//! .segment_duration(Duration::from_secs(6))
27//! .keyframe_interval(48)
28//! .build()?
29//! .write()?;
30//! ```
31//!
32//! ### DASH Output
33//!
34//! ```ignore
35//! use ff_stream::DashOutput;
36//! use std::time::Duration;
37//!
38//! DashOutput::new("/var/www/dash")
39//! .input("source.mp4")
40//! .segment_duration(Duration::from_secs(4))
41//! .build()?
42//! .write()?;
43//! ```
44//!
45//! ### ABR Ladder
46//!
47//! ```ignore
48//! use ff_stream::{AbrLadder, Rendition};
49//!
50//! AbrLadder::new("source.mp4")
51//! .add_rendition(Rendition { width: 1920, height: 1080, bitrate: 6_000_000 })
52//! .add_rendition(Rendition { width: 1280, height: 720, bitrate: 3_000_000 })
53//! .add_rendition(Rendition { width: 854, height: 480, bitrate: 1_500_000 })
54//! .hls("/var/www/hls")?;
55//! ```
56//!
57//! ## Module Structure
58//!
59//! - [`hls`] — [`HlsOutput`]: segmented HLS output builder
60//! - [`dash`] — [`DashOutput`]: segmented DASH output builder
61//! - [`abr`] — [`AbrLadder`] + [`Rendition`]: multi-rendition ABR ladder
62//! - [`error`] — [`StreamError`]: unified error type for this crate
63//!
64//! ## Status
65//!
66//! The public API is stable. HLS and DASH muxing are fully implemented via the
67//! `FFmpeg` HLS/DASH muxers. `write()` / `hls()` / `dash()` perform real
68//! encode-and-mux operations against the filesystem.
69
70#![warn(missing_docs)]
71
72pub mod abr;
73pub(crate) mod codec_utils;
74pub mod dash;
75pub(crate) mod dash_inner;
76/// Unified error type for the `ff-stream` crate.
77pub mod error;
78pub mod hls;
79pub(crate) mod hls_inner;
80
81pub use abr::{AbrLadder, Rendition};
82pub use dash::DashOutput;
83pub use error::StreamError;
84pub use hls::HlsOutput;