pub struct Audio(pub Encoder);Tuple Fields§
§0: EncoderImplementations§
Source§impl Audio
impl Audio
pub fn open(self) -> Result<Encoder, Error>
pub fn open_as<E: Encoder>(self, codec: E) -> Result<Encoder, Error>
pub fn open_with(self, options: Dictionary<'_>) -> Result<Encoder, Error>
pub fn open_as_with<E: Encoder>( self, codec: E, options: Dictionary<'_>, ) -> Result<Encoder, Error>
pub fn set_rate(&mut self, rate: i32)
pub fn rate(&self) -> u32
pub fn set_format(&mut self, value: Sample)
pub fn format(&self) -> Sample
pub fn set_channel_layout(&mut self, value: ChannelLayout)
pub fn channel_layout(&self) -> ChannelLayout
pub fn set_channels(&mut self, value: i32)
pub fn channels(&self) -> u16
Methods from Deref<Target = Super>§
Sourcepub fn send_frame(&mut self, frame: &Frame) -> Result<(), Error>
pub fn send_frame(&mut self, frame: &Frame) -> Result<(), Error>
Sends a raw frame to the encoder.
The encoder will buffer and encode the frame according to its configuration.
Call receive_packet() to retrieve encoded packets.
§Errors
Error::Other(EAGAIN)- The encoder needs more frames before producing outputError::Eof- The encoder has been flushed and won’t accept more frames- Other errors indicate encoding failure
Sourcepub fn send_eof(&mut self) -> Result<(), Error>
pub fn send_eof(&mut self) -> Result<(), Error>
Signals end-of-stream and enters draining mode.
After calling this, continue calling receive_packet()
until it returns Error::Eof to retrieve all buffered encoded packets.
§Errors
Returns an error if the encoder is in an invalid state.
Sourcepub fn receive_packet<P: Mut>(&mut self, packet: &mut P) -> Result<(), Error>
pub fn receive_packet<P: Mut>(&mut self, packet: &mut P) -> Result<(), Error>
Receives an encoded packet from the encoder.
Call this repeatedly after send_frame() to retrieve
all available encoded packets.
§Errors
Error::Other(EAGAIN)- Need to send more frames before output is availableError::Eof- No more packets (encoder has been drained)- Other errors indicate encoding failure
Sourcepub fn set_bit_rate(&mut self, value: usize)
pub fn set_bit_rate(&mut self, value: usize)
Sets the target bitrate in bits per second.
This is the average bitrate the encoder will try to achieve. Used for CBR (constant bitrate) or ABR (average bitrate) encoding.
Sourcepub fn set_max_bit_rate(&mut self, value: usize)
pub fn set_max_bit_rate(&mut self, value: usize)
Sets the maximum bitrate in bits per second for VBR encoding.
Combined with bitrate, this defines the bitrate range for variable bitrate encoding. The encoder will never exceed this bitrate.
Sourcepub fn set_tolerance(&mut self, value: usize)
pub fn set_tolerance(&mut self, value: usize)
Sets the bitrate tolerance for rate control.
Defines how much the bitrate can deviate from the target. Higher values allow more variation (better quality in complex scenes) but less consistent bitrate.
Sourcepub fn set_quality(&mut self, value: usize)
pub fn set_quality(&mut self, value: usize)
Sets the global quality/quantizer for quality-based encoding.
Interpretation is codec-specific. For example:
- MPEG-2/4: Use 1 (best) to 31 (worst)
- H.264: Use with CRF mode
Lower values = higher quality = larger file size.
Sourcepub fn set_compression(&mut self, value: Option<usize>)
pub fn set_compression(&mut self, value: Option<usize>)
Sets the compression level.
Codec-specific parameter controlling the speed/compression tradeoff. Higher values = slower encoding but better compression.
Pass None to use the codec’s default (-1).