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
72#[macro_use]
73mod builder_macros;
74
75pub mod abr;
76pub(crate) mod codec_utils;
77pub mod dash;
78pub(crate) mod dash_inner;
79/// Unified error type for the `ff-stream` crate.
80pub mod error;
81pub mod fanout;
82pub mod hls;
83pub(crate) mod hls_inner;
84pub mod live_abr;
85pub mod live_dash;
86pub(crate) mod live_dash_inner;
87pub mod live_hls;
88pub(crate) mod live_hls_inner;
89pub(crate) mod muxer_core;
90pub mod output;
91pub mod rtmp;
92pub(crate) mod rtmp_inner;
93#[cfg(feature = "srt")]
94pub mod srt_output;
95#[cfg(feature = "srt")]
96pub(crate) mod srt_output_inner;
97
98pub use abr::{AbrLadder, Rendition};
99pub use dash::DashOutput;
100pub use error::StreamError;
101pub use fanout::FanoutOutput;
102pub use hls::{HlsOutput, HlsSegmentFormat};
103pub use live_abr::{AbrRendition, LiveAbrFormat, LiveAbrLadder};
104pub use live_dash::LiveDashOutput;
105pub use live_hls::LiveHlsOutput;
106pub use output::StreamOutput;
107pub use rtmp::RtmpOutput;
108#[cfg(feature = "srt")]
109pub use srt_output::SrtOutput;