Skip to main content

DashOutput

Struct DashOutput 

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

Builds and writes a DASH segmented output.

DashOutput follows the consuming-builder pattern: each setter takes self and returns a new Self, and the final build call validates the configuration before returning a ready-to-write instance.

§Examples

use ff_stream::DashOutput;
use std::time::Duration;

DashOutput::new("/var/www/dash")
    .input("source.mp4")
    .segment_duration(Duration::from_secs(4))
    .build()?
    .write()?;

Implementations§

Source§

impl DashOutput

Source

pub fn new(output_dir: &str) -> Self

Create a new builder targeting output_dir.

The directory does not need to exist at construction time; it will be created (if absent) by the FFmpeg DASH muxer when write is called.

Default: segment duration = 4 s.

Source

pub fn input(self, path: &str) -> Self

Set the input media file path.

This is required; build will return StreamError::InvalidConfig if no input is supplied.

Source

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

Override the DASH segment duration (default: 4 s).

MPEG-DASH recommends 2–10 s segments; 4 s is a common default that balances latency against the overhead of many small files.

Source

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

Validate the configuration and return a ready-to-write DashOutput.

§Errors
§Examples
use ff_stream::DashOutput;

// Missing input → error
assert!(DashOutput::new("/tmp/dash").build().is_err());

// Valid configuration → ok
assert!(DashOutput::new("/tmp/dash").input("src.mp4").build().is_ok());
Source

pub fn write(self) -> Result<(), StreamError>

Write DASH segments to the output directory.

On success the output directory will contain a manifest.mpd file and the corresponding initialization and media segments.

§Errors

Returns StreamError::InvalidConfig when the builder is not fully configured, or StreamError::Ffmpeg when an FFmpeg operation fails.

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.