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:
push_videoandpush_audioforward frames to all renditions (each scales internally via its ownSwsContext).StreamOutput::finishflushes all encoders and writes the master playlist.
All rendition subdirectories are created by build() if they do not exist.
Implementations§
Source§impl LiveAbrLadder
impl LiveAbrLadder
Sourcepub fn add_rendition(self, rendition: AbrRendition) -> Self
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.
Sourcepub fn format(self, format: LiveAbrFormat) -> Self
pub fn format(self, format: LiveAbrFormat) -> Self
Set the output container format.
Default: LiveAbrFormat::Hls.
Sourcepub fn fps(self, fps: f64) -> Self
pub fn fps(self, fps: f64) -> Self
Set the frame rate used for all renditions.
This method must be called before build.
Sourcepub fn audio(self, sample_rate: u32, channels: u32) -> Self
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.
Sourcepub fn segment_duration(self, duration: Duration) -> Self
pub fn segment_duration(self, duration: Duration) -> Self
Set the target segment duration for all renditions.
Default: 6 seconds.
Sourcepub fn playlist_size(self, size: u32) -> Self
pub fn playlist_size(self, size: u32) -> Self
Set the sliding-window playlist size (HLS only).
Default: 5.
Sourcepub fn video_codec(self, codec: VideoCodec) -> Self
pub fn video_codec(self, codec: VideoCodec) -> Self
Set the video codec for all renditions.
Default: VideoCodec::H264.
Sourcepub fn build(self) -> Result<Self, StreamError>
pub fn build(self) -> Result<Self, StreamError>
Open all per-rendition FFmpeg contexts.
§Errors
Returns StreamError::InvalidConfig when:
output_diris empty.- No renditions have been added.
fpswas not called.
Returns StreamError::Io when a rendition subdirectory cannot be
created. Returns StreamError::Ffmpeg when any FFmpeg operation
fails.