pub struct NativeVideoEncodeSink { /* private fields */ }Expand description
Transactional FFmpeg video encoder and muxer.
Frames go to a sibling partial file, renamed to the destination only after a successful drain and trailer write.
Implementations§
Source§impl NativeVideoEncodeSink
impl NativeVideoEncodeSink
Sourcepub fn create(
path: impl Into<OutputTarget>,
config: VideoEncodeConfig,
) -> Result<Self, EncodeError>
pub fn create( path: impl Into<OutputTarget>, 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 Into<OutputTarget>,
config: VideoEncodeConfig,
encoder_name: &str,
) -> Result<Self, EncodeError>
pub fn create_with_encoder( path: impl Into<OutputTarget>, 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 Into<OutputTarget>,
config: VideoEncodeConfig,
encoder_name: Option<&str>,
software_threads: &dyn Fn(Option<usize>) -> i64,
) -> Result<Self, EncodeError>
pub fn create_with_encoder_threads( path: impl Into<OutputTarget>, config: VideoEncodeConfig, encoder_name: Option<&str>, software_threads: &dyn Fn(Option<usize>) -> i64, ) -> Result<Self, EncodeError>
Creates an encoder whose software thread count the caller decides.
software_threads is asked at most once, only when a CPU candidate opens, so a hardware
candidate that falls through to software still gets a software share of the CPU.
encoder_name pins one encoder (that one or an error); None tries the codec’s
candidates in preference order.
§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.
EncodeEvent::Video copies engine planes into a new AVFrame on the encode worker, the
saturated thread; a caller that packed straight into an encoder frame hands it over instead.
§Errors
Returns an error for a frame sized differently from this encoder, a non-monotonic timestamp, or a codec failure.
Source§impl NativeVideoEncodeSink
impl NativeVideoEncodeSink
Sourcepub fn publish_report(&self) -> Option<PublishReport>
pub fn publish_report(&self) -> Option<PublishReport>
How the finished file was published; None until it is.
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 Forget for NativeVideoEncodeSink
impl Freeze for NativeVideoEncodeSinkwhere
*const AVFormatContext is !null: Freeze,
*const AVIOContext is !null: Freeze,
*const Opaque is !null: Freeze,
PhantomData<Opaque>: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
I32NotAllOnes: Freeze,
*const AVCodecContext is !null: Freeze,
*const OpenH264Encoder is !null: Freeze,
PhantomData<OpenH264Encoder>: Freeze,
*const AVBSFContext is !null: Freeze,
PhantomData<AVPacket>: Freeze,
*const SwsContext is !null: Freeze,
*const AVFrame is !null: Freeze,
PhantomData<NativeVideoEncoderFallback>: Freeze,
impl Move for NativeVideoEncodeSink
impl Send for NativeVideoEncodeSinkwhere
AVFormatContextOutput: Send,
RawVecInner: Send,
I32NotAllOnes: Send,
AVCodecContext: Send,
BoxRaw<OpenH264Encoder>: Send,
AVBSFContextUninit: Send,
AVPacket: Send,
SwsContext: Send,
AVFrame: Send,
impl Unpin for NativeVideoEncodeSinkwhere
*const AVFormatContext is !null: Unpin,
*const AVIOContext is !null: Unpin,
Box<Opaque>: Unpin,
*const u8 is !null: Unpin,
I32NotAllOnes: Unpin,
*const AVCodecContext is !null: Unpin,
Box<OpenH264Encoder>: Unpin,
*const AVBSFContext is !null: Unpin,
*const AVPacket is !null: Unpin,
*const SwsContext is !null: Unpin,
*const AVFrame is !null: Unpin,
impl UnsafeUnpin for NativeVideoEncodeSinkwhere
*const AVFormatContext is !null: UnsafeUnpin,
*const AVIOContext is !null: UnsafeUnpin,
*const Opaque is !null: UnsafeUnpin,
PhantomData<Opaque>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
I32NotAllOnes: UnsafeUnpin,
*const AVCodecContext is !null: UnsafeUnpin,
*const OpenH264Encoder is !null: UnsafeUnpin,
PhantomData<OpenH264Encoder>: UnsafeUnpin,
*const AVBSFContext is !null: UnsafeUnpin,
PhantomData<AVPacket>: UnsafeUnpin,
*const SwsContext is !null: UnsafeUnpin,
*const AVFrame is !null: UnsafeUnpin,
PhantomData<NativeVideoEncoderFallback>: UnsafeUnpin,
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