Skip to main content

LiveDashOutput

Struct LiveDashOutput 

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

Live DASH output: receives frames and writes a manifest.mpd playlist.

Build with LiveDashOutput::new, chain setter methods, then call build to open the FFmpeg contexts. After build():

The output directory is created automatically by build() if it does not exist.

Implementations§

Source§

impl LiveDashOutput

Source

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

Create a new builder that writes DASH output to output_dir.

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

§Example
use ff_stream::LiveDashOutput;

let out = LiveDashOutput::new("/var/www/live");
Source

pub fn video(self, width: u32, height: u32, fps: f64) -> Self

Set the video encoding parameters.

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 this method is not called, audio is disabled.

Source

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

Set the target DASH segment duration.

Default: 4 seconds.

Source

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

Set the video codec.

Default: VideoCodec::H264.

Source

pub fn audio_codec(self, codec: AudioCodec) -> Self

Set the audio codec.

Default: AudioCodec::Aac.

Source

pub fn video_bitrate(self, bitrate: u64) -> Self

Set the video encoder target bit rate in bits/s.

Default: 2 000 000 (2 Mbit/s).

Source

pub fn audio_bitrate(self, bitrate: u64) -> Self

Set the audio encoder target bit rate in bits/s.

Default: 128 000 (128 kbit/s).

Source

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

Open all FFmpeg contexts and write the DASH header.

§Errors

Returns StreamError::InvalidConfig when:

  • output_dir is empty.
  • video was not called before build.

Returns StreamError::Io when the output directory cannot be created. Returns StreamError::Ffmpeg when any FFmpeg operation fails.

Trait Implementations§

Source§

impl StreamOutput for LiveDashOutput

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.