pub struct NativeVideoEncodeSink { /* private fields */ }Expand description
Transactional FFmpeg video encoder and muxer.
Frames are encoded into a sibling partial file. Only a successful encoder drain and trailer write renames it to the requested destination.
Implementations§
Source§impl NativeVideoEncodeSink
impl NativeVideoEncodeSink
Sourcepub fn create(
path: impl AsRef<Path>,
config: VideoEncodeConfig,
) -> Result<Self, EncodeError>
pub fn create( path: impl AsRef<Path>, config: VideoEncodeConfig, ) -> Result<Self, EncodeError>
Creates a sink that encodes config.codec into a config.container file at path.
§Errors
Returns an adapter failure for invalid dimensions, paths, codecs, or muxers.
Sourcepub fn create_with_encoder(
path: impl AsRef<Path>,
config: VideoEncodeConfig,
encoder_name: &str,
) -> Result<Self, EncodeError>
pub fn create_with_encoder( path: impl AsRef<Path>, config: VideoEncodeConfig, encoder_name: &str, ) -> Result<Self, EncodeError>
Creates a concrete encoder selected by its FFmpeg short name.
§Errors
Returns an adapter failure when the name is unavailable, implements a different codec, or the remaining configuration is invalid.
Sourcepub fn create_with_encoder_threads(
path: impl AsRef<Path>,
config: VideoEncodeConfig,
encoder_name: Option<&str>,
software_threads: &dyn Fn() -> i64,
) -> Result<Self, EncodeError>
pub fn create_with_encoder_threads( path: impl AsRef<Path>, config: VideoEncodeConfig, 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: a caller that names an
encoder gets that one or an error.
§Errors
Returns an adapter failure when no candidate opens or the output configuration is invalid.
Sourcepub fn stage_timings(&self) -> EncodeStageTimings
pub fn stage_timings(&self) -> EncodeStageTimings
Where this sink’s time has gone so far.
Sourcepub fn selection(&self) -> &NativeVideoEncoderSelection
pub fn selection(&self) -> &NativeVideoEncoderSelection
The 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.
An EncodeEvent::Video written to the sink takes engine planes and
allocates an AVFrame to copy them into, on this thread: the encode
worker, which is the saturated one. A caller that packed its own output
straight into an encoder frame hands that frame over instead.
§Errors
Returns an error for a frame sized differently from this encoder, a non-monotonic timestamp, or a codec failure.
Trait Implementations§
Source§impl Drop for NativeVideoEncodeSink
impl Drop for NativeVideoEncodeSink
Source§impl EncodeSink for NativeVideoEncodeSink
impl EncodeSink for NativeVideoEncodeSink
Source§fn write(
&mut self,
event: EncodeEvent,
cancel: &CancelToken,
) -> Result<(), EncodeError>
fn write( &mut self, event: EncodeEvent, cancel: &CancelToken, ) -> Result<(), EncodeError>
Source§fn finish(&mut self, cancel: &CancelToken) -> Result<(), EncodeError>
fn finish(&mut self, cancel: &CancelToken) -> Result<(), EncodeError>
Auto Trait Implementations§
impl !RefUnwindSafe for NativeVideoEncodeSink
impl !Sync for NativeVideoEncodeSink
impl !UnwindSafe for NativeVideoEncodeSink
impl Freeze for NativeVideoEncodeSink
impl Send for NativeVideoEncodeSink
impl Unpin for NativeVideoEncodeSink
impl UnsafeUnpin for NativeVideoEncodeSink
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more