pub struct EncodeSink { /* private fields */ }Expand description
Turns an export’s pictures and mixed audio into a container’s tracks.
Tracks are added once every encoder has published its configuration record; packets before that wait. Audio goes to the writer at most one second ahead of the video written, so a mix encoded before the pictures still reaches the writer interleaved with them.
Implementations§
Source§impl EncodeSink
impl EncodeSink
Sourcepub fn new(
writer: Box<dyn ContainerWriter>,
video: Box<dyn VideoEncodeBackend>,
video_config: VideoEncodeConfig,
audio: Option<(Box<dyn AudioEncodeBackend>, AudioEncodeConfig)>,
cancel: CancelToken,
) -> Self
pub fn new( writer: Box<dyn ContainerWriter>, video: Box<dyn VideoEncodeBackend>, video_config: VideoEncodeConfig, audio: Option<(Box<dyn AudioEncodeBackend>, AudioEncodeConfig)>, cancel: CancelToken, ) -> Self
A sink writing video (and audio, when the export has sound) into writer; cancel
stops its waits on a busy encoder.
Sourcepub fn video_encoder(&self) -> (&str, bool, AppliedRateControl)
pub fn video_encoder(&self) -> (&str, bool, AppliedRateControl)
The video encoder’s name and the rate control it ran.
Sourcepub fn finish(self) -> Result<(), EncodeError>
pub fn finish(self) -> Result<(), EncodeError>
Ends both inputs, drains the encoders and closes the output.
§Errors
As Self::write_frame; encoders that give no packet for 10 s while draining, or an
encoder that never published its configuration.
Source§impl EncodeSink
impl EncodeSink
Sourcepub fn write_frame(
&mut self,
index: u64,
planes: &[PlaneBuffer],
) -> Result<(), EncodeError>
pub fn write_frame( &mut self, index: u64, planes: &[PlaneBuffer], ) -> Result<(), EncodeError>
Encodes frame index of the export, its planes in the configured layout.
§Errors
EncodeError::EncoderRejected for any failure of the video encoder; a writer or audio
encoder failure as it is; EncodeError::Cancelled when the token is set while an encoder
is busy; an encoder that takes no frame and gives no packet for 10 s.
Trait Implementations§
Source§impl AudioBlockSink for EncodeSink
impl AudioBlockSink for EncodeSink
Source§fn write_audio(
&mut self,
block: &AudioBlock,
cancel: &CancelToken,
) -> Result<(), EncodeError>
fn write_audio( &mut self, block: &AudioBlock, cancel: &CancelToken, ) -> Result<(), EncodeError>
Source§fn finish_audio(&mut self, _cancel: &CancelToken) -> Result<(), EncodeError>
fn finish_audio(&mut self, _cancel: &CancelToken) -> Result<(), EncodeError>
Source§fn abort_audio(&mut self) -> Result<(), EncodeError>
fn abort_audio(&mut self) -> Result<(), EncodeError>
Source§impl Debug for EncodeSink
impl Debug for EncodeSink
Source§impl VideoSink for EncodeSink
Available on crate feature engine only.
impl VideoSink for EncodeSink
engine only.Source§fn write_video(
&mut self,
index: u64,
_time: MediaTime,
_layout: PixelLayout,
planes: &[PlaneBuffer],
) -> Result<(), EncodeError>
fn write_video( &mut self, index: u64, _time: MediaTime, _layout: PixelLayout, planes: &[PlaneBuffer], ) -> Result<(), EncodeError>
Auto Trait Implementations§
impl !RefUnwindSafe for EncodeSink
impl !Sync for EncodeSink
impl !UnwindSafe for EncodeSink
impl Forget for EncodeSink
impl Freeze for EncodeSink
impl Move for EncodeSink
impl Send for EncodeSink
impl Unpin for EncodeSink
impl UnsafeUnpin for EncodeSink
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