pub struct VideoEncoder { /* private fields */ }Expand description
Implementations§
Source§impl VideoEncoder
impl VideoEncoder
Sourcepub fn new(config: EncoderConfig) -> Result<Self>
pub fn new(config: EncoderConfig) -> Result<Self>
Opens an encoder for config.
On Linux the first V4L2 memory-to-memory device that produces the
codec and accepts the input format is used. Setting
EDGEFIRST_CODEC_V4L2_ENCODER to a device node uses that node only.
§Errors
CodecError::InvalidConfig when config is invalid or the device
rejects it, CodecError::UnsupportedFormat when no device accepts
the input format, and CodecError::NoDevice when there is no
encoder.
Sourcepub fn encode(
&mut self,
src: &TensorDyn,
opts: &FrameOptions,
) -> Result<Option<EncodedFrame>>
pub fn encode( &mut self, src: &TensorDyn, opts: &FrameOptions, ) -> Result<Option<EncodedFrame>>
Encodes src.
src must have the configured input format and, without a crop, the
configured size. DMA-BUF sources are read in place: the call returns
once the device has finished reading src, so the caller may reuse
it afterwards. Every source of one stream must have the same row
stride.
Returns the next finished access unit, which may belong to an earlier
frame, or None when none is ready yet.
Sourcepub fn flush(&mut self) -> Result<Vec<EncodedFrame>>
pub fn flush(&mut self) -> Result<Vec<EncodedFrame>>
Drains the encoder: returns every access unit not yet returned, in order. The encoder accepts new frames afterwards.