Skip to main content

LiveAbrLadder

Struct LiveAbrLadder 

Source
pub struct LiveAbrLadder { /* private fields */ }
Expand description

Live ABR ladder: fans frames to multiple encoders at different resolutions.

Build with LiveAbrLadder::new, add renditions, configure encoding parameters, then call build. After that:

All rendition subdirectories are created by build() if they do not exist.

Implementations§

Source§

impl LiveAbrLadder

Source

pub fn new(output_dir: impl AsRef<Path>) -> Self

Create a new builder that writes the ABR ladder to output_dir.

Accepts any path-like value: "/var/www/live", Path::new(…), etc.

§Example
use ff_stream::LiveAbrLadder;

let ladder = LiveAbrLadder::new("/var/www/live");
Source

pub fn add_rendition(self, rendition: AbrRendition) -> Self

Add a rendition to the ladder.

At least one rendition is required; build returns StreamError::InvalidConfig when the list is empty.

Source

pub fn format(self, format: LiveAbrFormat) -> Self

Set the output container format.

Default: LiveAbrFormat::Hls.

Source

pub fn fps(self, fps: f64) -> Self

Set the frame rate used for all renditions.

This method must be called before build.

Source

pub fn audio(self, sample_rate: u32, channels: u32) -> Self

Enable audio output with the given sample rate and channel count.

If not called, audio is disabled for all renditions.

Source

pub fn segment_duration(self, duration: Duration) -> Self

Set the target segment duration for all renditions.

Default: 6 seconds.

Source

pub fn playlist_size(self, size: u32) -> Self

Set the sliding-window playlist size (HLS only).

Default: 5.

Source

pub fn video_codec(self, codec: VideoCodec) -> Self

Set the video codec for all renditions.

Default: VideoCodec::H264.

Source

pub fn build(self) -> Result<Self, StreamError>

Open all per-rendition FFmpeg contexts.

§Errors

Returns StreamError::InvalidConfig when:

  • output_dir is empty.
  • No renditions have been added.
  • fps was not called.

Returns StreamError::Io when a rendition subdirectory cannot be created. Returns StreamError::Ffmpeg when any FFmpeg operation fails.

Trait Implementations§

Source§

impl StreamOutput for LiveAbrLadder

Source§

fn push_video(&mut self, frame: &VideoFrame) -> Result<(), StreamError>

Push one video frame into the stream.
Source§

fn push_audio(&mut self, frame: &AudioFrame) -> Result<(), StreamError>

Push one audio frame into the stream.
Source§

fn finish(self: Box<Self>) -> Result<(), StreamError>

Flush all buffered data and close the output. Read more

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.