Skip to main content

AbrLadder

Struct AbrLadder 

Source
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

Source

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.

Source

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.

Source

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
§Examples
use ff_stream::{AbrLadder, Rendition};

// Empty ladder → error
assert!(AbrLadder::new("src.mp4").hls("/tmp/hls").is_err());
Source

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
§Examples
use ff_stream::{AbrLadder, Rendition};

// Empty ladder → error
assert!(AbrLadder::new("src.mp4").dash("/tmp/dash").is_err());

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.