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
impl DashOutput
Sourcepub fn new(output_dir: &str) -> Self
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.
Sourcepub fn input(self, path: &str) -> Self
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.
Sourcepub fn segment_duration(self, d: Duration) -> Self
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.
Sourcepub fn build(self) -> Result<Self, StreamError>
pub fn build(self) -> Result<Self, StreamError>
Validate the configuration and return a ready-to-write DashOutput.
§Errors
StreamError::InvalidConfigwhenoutput_diris empty.StreamError::InvalidConfigwhen no input path has been set viainput.
§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());Sourcepub fn write(self) -> Result<(), StreamError>
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.