pub trait VideoEncoder: Send + Sync {
// Required methods
fn push_video_frame(
&mut self,
bgra: &[u8],
pts: Duration,
) -> Result<(), EncodeError>;
fn push_audio_chunk(
&mut self,
samples: &[f32],
pts: Duration,
) -> Result<(), EncodeError>;
fn finalize(self: Box<Self>) -> Result<PathBuf, EncodeError>;
}Expand description
Encoder trait — the seam M-EXPORT.3 hooks the per-channel
capture callbacks into. Pure-sync interface; the
LiveGstreamerEncoder impl streams each pushed frame into a
gst-launch-1.0 child and remuxes in the audio at finalize.
Required Methods§
Sourcefn push_video_frame(
&mut self,
bgra: &[u8],
pts: Duration,
) -> Result<(), EncodeError>
fn push_video_frame( &mut self, bgra: &[u8], pts: Duration, ) -> Result<(), EncodeError>
Push one BGRA frame at the given monotonic PTS (measured from
session start). bgra.len() must equal width * height * 4.
§Errors
Returns EncodeError::Io on scratch-file write failure.
Sourcefn push_audio_chunk(
&mut self,
samples: &[f32],
pts: Duration,
) -> Result<(), EncodeError>
fn push_audio_chunk( &mut self, samples: &[f32], pts: Duration, ) -> Result<(), EncodeError>
Push interleaved F32LE audio samples at the given PTS.
Sample layout is [ch0, ch1, ch0, ch1, ...] for stereo.
§Errors
Returns EncodeError::Io on scratch-file write failure.
Sourcefn finalize(self: Box<Self>) -> Result<PathBuf, EncodeError>
fn finalize(self: Box<Self>) -> Result<PathBuf, EncodeError>
Finalize: spawn the gst-launch pipeline that consumes the
scratch files and writes the final container at the configured
output path. Consumes self because the encoder is single-use.
§Errors
EncodeError::Spawn— gst-launch missing from PATH.EncodeError::PipelineFailed— gst-launch exited non-zero.EncodeError::Unsupported— format/OS combo not wired.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".