Skip to main content

NativeVideoEncodeSink

Struct NativeVideoEncodeSink 

Source
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

Source

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.

Source

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.

Source

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.

Source

pub fn stage_timings(&self) -> EncodeStageTimings

Where this sink’s time has gone so far.

Source

pub fn selection(&self) -> &NativeVideoEncoderSelection

The encoder this sink opened, and the candidates it passed over.

Source

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

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl EncodeSink for NativeVideoEncodeSink

Source§

fn write( &mut self, event: EncodeEvent, cancel: &CancelToken, ) -> Result<(), EncodeError>

Queues one timestamped media item. Read more
Source§

fn finish(&mut self, cancel: &CancelToken) -> Result<(), EncodeError>

Drains encoder delay, interleaves remaining packets, and writes the trailer. Read more
Source§

fn abort(&mut self) -> Result<(), EncodeError>

Aborts and applies the adapter’s partial-output cleanup policy. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,