pub struct EncoderContext(/* private fields */);Expand description
An encoder context that is closed under the MediaFoundation lock when it
is one of the _mf encoders (see open_codec_context), and dropped as
usual otherwise. It reads and writes as the AVCodecContext it holds.
Methods from Deref<Target = AVCodecContext>§
pub fn as_ptr(&self) -> *const AVCodecContext
pub fn as_mut_ptr(&mut self) -> *mut AVCodecContext
Sourcepub unsafe fn set_ptr(&mut self, ptr: NonNull<AVCodecContext>)
pub unsafe fn set_ptr(&mut self, ptr: NonNull<AVCodecContext>)
§Safety
This function should only be called when the pointer is valid and the data it’s pointing to can be dropped.
pub fn set_framerate(&mut self, framerate: AVRational)
pub fn set_ch_layout(&mut self, ch_layout: AVChannelLayout)
pub fn set_height(&mut self, height: i32)
pub fn set_width(&mut self, width: i32)
pub fn set_sample_aspect_ratio(&mut self, sample_aspect_ratio: AVRational)
pub fn set_pix_fmt(&mut self, pix_fmt: i32)
pub fn set_time_base(&mut self, time_base: AVRational)
pub fn set_pkt_timebase(&mut self, pkt_timebase: AVRational)
pub fn set_sample_rate(&mut self, sample_rate: i32)
pub fn set_sample_fmt(&mut self, sample_fmt: i32)
pub fn set_flags(&mut self, flags: i32)
pub fn set_bit_rate(&mut self, bit_rate: i64)
pub fn set_strict_std_compliance(&mut self, strict_std_compliance: i32)
pub fn set_gop_size(&mut self, gop_size: i32)
pub fn set_max_b_frames(&mut self, max_b_frames: i32)
pub fn set_get_format( &mut self, get_format: Option<unsafe extern "C" fn(*mut AVCodecContext, *const i32) -> i32>, )
Sourcepub fn open(
&mut self,
dict: Option<AVDictionary>,
) -> Result<Option<AVDictionary>, RsmpegError>
pub fn open( &mut self, dict: Option<AVDictionary>, ) -> Result<Option<AVDictionary>, RsmpegError>
Initialize the AVCodecContext.
dict: A AVDictionary filled with AVCodecContext and AVCodec
private options. Function returns a AVDictionary filled with
options that were not found if given dictionary. It can usually be
ignored.
Note: Always call this function before using decoding routines, such as Self::receive_frame().
Sourcepub fn send_packet(
&mut self,
packet: Option<&AVPacket>,
) -> Result<(), RsmpegError>
pub fn send_packet( &mut self, packet: Option<&AVPacket>, ) -> Result<(), RsmpegError>
Trying to push a packet to current decoding_context(AVCodecContext).
Sourcepub fn receive_frame(&mut self) -> Result<AVFrame, RsmpegError>
pub fn receive_frame(&mut self) -> Result<AVFrame, RsmpegError>
Trying to pull a frame from current decoding_context(AVCodecContext).
Sourcepub fn send_frame(&mut self, frame: Option<&AVFrame>) -> Result<(), RsmpegError>
pub fn send_frame(&mut self, frame: Option<&AVFrame>) -> Result<(), RsmpegError>
Trying to push a frame to current encoding_context(AVCodecContext).
Sourcepub fn receive_packet(&mut self) -> Result<AVPacket, RsmpegError>
pub fn receive_packet(&mut self) -> Result<AVPacket, RsmpegError>
Trying to pull a packet from current encoding_context(AVCodecContext).
Sourcepub fn decode_subtitle(
&mut self,
packet: Option<&mut AVPacket>,
) -> Result<Option<AVSubtitle>, RsmpegError>
pub fn decode_subtitle( &mut self, packet: Option<&mut AVPacket>, ) -> Result<Option<AVSubtitle>, RsmpegError>
Decode a subtitle message.
Some decoders (those marked with AV_CODEC_CAP_DELAY) have a delay
between input and output. This means that for some packets they will not
immediately produce decoded output and need to be flushed at the end of
decoding to get all the decoded data. Flushing is done by calling this
function with None.
Sourcepub fn encode_subtitle(
&mut self,
subtitle: &AVSubtitle,
buf: &mut [u8],
) -> Result<(), RsmpegError>
pub fn encode_subtitle( &mut self, subtitle: &AVSubtitle, buf: &mut [u8], ) -> Result<(), RsmpegError>
Encode subtitle to buffer.
Sourcepub fn apply_codecpar(
&mut self,
codecpar: &AVCodecParameters,
) -> Result<(), RsmpegError>
pub fn apply_codecpar( &mut self, codecpar: &AVCodecParameters, ) -> Result<(), RsmpegError>
Fill the codec context based on the values from the supplied codec parameters.
ATTENTION: There is no codecpar field in AVCodecContext, this function
just fill the codec context based on the values from the supplied codec
parameters. Any allocated fields in current AVCodecContext that have a
corresponding field in codecpar are freed and replaced with duplicates
of the corresponding field in codecpar. Fields in current
AVCodecContext that do not have a counterpart in given codecpar are
not touched.
Sourcepub fn extract_codecpar(&self) -> AVCodecParameters
pub fn extract_codecpar(&self) -> AVCodecParameters
Get a filled AVCodecParameters based on the values from current AVCodecContext.
Sourcepub fn ch_layout(&self) -> AVChannelLayoutRef<'_>
pub fn ch_layout(&self) -> AVChannelLayoutRef<'_>
Get channel layout
pub fn hw_frames_ctx(&self) -> Option<AVHWFramesContextRef<'_>>
pub fn hw_frames_ctx_mut(&mut self) -> Option<AVHWFramesContextMut<'_>>
pub fn set_hw_frames_ctx(&mut self, hw_frames_ctx: AVHWFramesContext)
pub fn set_hw_device_ctx(&mut self, hw_device_ctx: AVHWDeviceContext)
Sourcepub fn get_supported_pix_fmts(
&self,
codec: Option<&AVCodec>,
) -> Result<&[i32], RsmpegError>
pub fn get_supported_pix_fmts( &self, codec: Option<&AVCodec>, ) -> Result<&[i32], RsmpegError>
Retrieve a list of all supported pixel formats.
Returns Some(&[]) if all possible pixel formats are supported
avctx: codec The codec to query, or None to use self.codec
Sourcepub fn get_supported_sample_fmts(
&self,
codec: Option<&AVCodec>,
) -> Result<&[i32], RsmpegError>
pub fn get_supported_sample_fmts( &self, codec: Option<&AVCodec>, ) -> Result<&[i32], RsmpegError>
Retrieve a list of all supported sample formats.
Returns Some(&[]) if all possible sample formats are supported
avctx: codec The codec to query, or None to use self.codec
Sourcepub unsafe fn get_supported_config<T>(
&self,
codec: Option<&AVCodec>,
config: u32,
) -> Result<&[T], RsmpegError>
pub unsafe fn get_supported_config<T>( &self, codec: Option<&AVCodec>, config: u32, ) -> Result<&[T], RsmpegError>
Retrieve a list of all supported values for a given configuration type.
§Safety
config should matches T
Sourcepub fn is_hwaccel(&self) -> bool
pub fn is_hwaccel(&self) -> bool
Is hardware accelaration enabled in this codec context.
Sourcepub fn flush_buffers(&mut self)
pub fn flush_buffers(&mut self)
Reset the internal codec state / flush internal buffers. Should be called e.g. when seeking or when switching to a different stream.
For decoders, this function just releases any references the decoder might keep internally, but the caller’s references remain valid.
For encoders, this function will only do something if the encoder declares support for AV_CODEC_CAP_ENCODER_FLUSH. When called, the encoder will drain any remaining packets, and can then be re-used for a different stream (as opposed to sending a null frame which will leave the encoder in a permanent EOF state after draining). This can be desirable if the cost of tearing down and replacing the encoder instance is high.
Sourcepub fn codec(&'ctx self) -> AVCodecRef<'ctx>
pub fn codec(&'ctx self) -> AVCodecRef<'ctx>
Get a reference to the AVCodec in current codec context.