pub struct NativeAvEncodeSink { /* private fields */ }Expand description
Audio/video sink that encodes and interleaves through the linked FFmpeg
libraries without requiring command-line programs on the host. Video frames
and audio blocks must be submitted in nondecreasing start-timestamp order;
ready packets are muxed incrementally instead of retained for the full file.
Implementations§
Source§impl NativeAvEncodeSink
impl NativeAvEncodeSink
Sourcepub fn create(
path: impl AsRef<Path>,
config: AvEncodeConfig,
) -> Result<Self, EncodeError>
pub fn create( path: impl AsRef<Path>, config: AvEncodeConfig, ) -> Result<Self, EncodeError>
Creates linked-library video, audio, and container encoders without touching the final destination.
§Errors
Returns an encoder error for invalid configuration, paths, or stale component outputs.
Sourcepub fn create_with_video_encoder(
path: impl AsRef<Path>,
config: AvEncodeConfig,
encoder_name: &str,
) -> Result<Self, EncodeError>
pub fn create_with_video_encoder( path: impl AsRef<Path>, config: AvEncodeConfig, encoder_name: &str, ) -> Result<Self, EncodeError>
Creates the requested concrete video encoder by its FFmpeg short name.
§Errors
Returns an encoder error when the name is unavailable, implements a different codec, or the remaining configuration is invalid.
Sourcepub fn create_with_video_encoder_threads(
path: impl AsRef<Path>,
config: AvEncodeConfig,
encoder_name: Option<&str>,
software_threads: &dyn Fn() -> i64,
) -> Result<Self, EncodeError>
pub fn create_with_video_encoder_threads( path: impl AsRef<Path>, config: AvEncodeConfig, encoder_name: Option<&str>, software_threads: &dyn Fn() -> i64, ) -> Result<Self, EncodeError>
Creates an encoder whose software thread count the caller decides.
software_threads is asked, at most once, only when a candidate that
runs on the CPU is opened: the caller sizes the rest of its work from
NativeVideoEncoderSelection afterwards, so a hardware candidate that
fails to open and falls through to software still gets a software
encoder’s share of the CPU.
encoder_name is the concrete encoder the caller pinned. None lets
the candidates for the codec be tried in preference order, which is
what makes the open-time fallback reachable.
§Errors
Returns an encoder error when no candidate opens, or for invalid configuration, paths, codecs, or muxers.
Sourcepub fn stage_timings(&self) -> EncodeStageTimings
pub fn stage_timings(&self) -> EncodeStageTimings
Where this sink’s time has gone so far, both threads together.
Sourcepub fn video_selection(&self) -> &NativeVideoEncoderSelection
pub fn video_selection(&self) -> &NativeVideoEncoderSelection
The video encoder this sink opened, and the candidates it passed over.
Sourcepub fn write_prepared_video(
&mut self,
frame: &mut Yuv420pFrameBuffer,
pts: MediaTime,
) -> Result<(), EncodeError>
pub fn write_prepared_video( &mut self, frame: &mut Yuv420pFrameBuffer, pts: MediaTime, ) -> Result<(), EncodeError>
Encodes a frame the caller already packed, without copying it.
See crate::NativeVideoEncodeSink::write_prepared_video; this is the
same handover for the muxed audio/video sink.
§Errors
Returns an error for a frame sized differently from this encoder, a non-monotonic timestamp, or a codec failure.