pub struct AbrLadder { /* private fields */ }Expand description
Produces multi-rendition HLS or DASH output from a single input.
AbrLadder accepts one or more Renditions and encodes the input at
each quality level, writing the results into a directory structure that a
player can consume with a single master playlist or MPD manifest.
§Examples
use ff_stream::{AbrLadder, Rendition};
AbrLadder::new("source.mp4")
.add_rendition(Rendition { width: 1920, height: 1080, bitrate: 6_000_000 })
.add_rendition(Rendition { width: 1280, height: 720, bitrate: 3_000_000 })
.hls("/var/www/hls")?;Implementations§
Source§impl AbrLadder
impl AbrLadder
Sourcepub fn new(input_path: &str) -> Self
pub fn new(input_path: &str) -> Self
Create a new ladder for the given input file.
No renditions are added at construction time; use
add_rendition to populate the ladder before
calling hls or dash.
Sourcepub fn add_rendition(self, r: Rendition) -> Self
pub fn add_rendition(self, r: Rendition) -> Self
Append a rendition to the ladder.
Renditions are encoded in the order they are added. By convention, list them from highest to lowest quality so that the master playlist presents them in that order.
Sourcepub fn hls(self, output_dir: &str) -> Result<(), StreamError>
pub fn hls(self, output_dir: &str) -> Result<(), StreamError>
Write a multi-variant HLS output to output_dir.
Each rendition is written to a numbered sub-directory
(output_dir/0/, output_dir/1/, …) containing its own
playlist.m3u8. A master playlist at output_dir/master.m3u8
references all renditions.
§Errors
StreamError::InvalidConfigwith"no renditions added"when the ladder is empty.- Any
StreamErrorreturned by the underlying HLS muxer.
§Examples
use ff_stream::{AbrLadder, Rendition};
// Empty ladder → error
assert!(AbrLadder::new("src.mp4").hls("/tmp/hls").is_err());Sourcepub fn dash(self, output_dir: &str) -> Result<(), StreamError>
pub fn dash(self, output_dir: &str) -> Result<(), StreamError>
Write a multi-representation DASH output to output_dir.
Each rendition is written to a numbered sub-directory
(output_dir/0/, output_dir/1/, …) containing its own
manifest.mpd and segments.
§Errors
StreamError::InvalidConfigwith"no renditions added"when the ladder is empty.- Any
StreamErrorreturned by the underlying DASH muxer.
§Examples
use ff_stream::{AbrLadder, Rendition};
// Empty ladder → error
assert!(AbrLadder::new("src.mp4").dash("/tmp/dash").is_err());