pub struct AudioEncoder { /* private fields */ }Expand description
Encodes audio frames to a file using FFmpeg.
§Construction
Use AudioEncoder::create() to get an AudioEncoderBuilder, then call
AudioEncoderBuilder::build():
ⓘ
use ff_encode::{AudioEncoder, AudioCodec};
let mut encoder = AudioEncoder::create("output.m4a")
.audio(48000, 2)
.audio_codec(AudioCodec::Aac)
.build()?;Implementations§
Source§impl AudioEncoder
impl AudioEncoder
Sourcepub fn create<P: AsRef<Path>>(path: P) -> AudioEncoderBuilder
pub fn create<P: AsRef<Path>>(path: P) -> AudioEncoderBuilder
Creates a builder for the specified output file path.
This method is infallible. Validation occurs when
AudioEncoderBuilder::build() is called.
Sourcepub fn actual_codec(&self) -> &str
pub fn actual_codec(&self) -> &str
Returns the name of the FFmpeg encoder actually used (e.g. "aac", "libopus").
Sourcepub fn push(&mut self, frame: &AudioFrame) -> Result<(), EncodeError>
pub fn push(&mut self, frame: &AudioFrame) -> Result<(), EncodeError>
Pushes an audio frame for encoding.
§Errors
Returns EncodeError if encoding fails or the encoder is not initialised.
Sourcepub fn finish(self) -> Result<(), EncodeError>
pub fn finish(self) -> Result<(), EncodeError>
Flushes remaining frames and writes the file trailer.
§Errors
Returns EncodeError if finalising fails.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AudioEncoder
impl RefUnwindSafe for AudioEncoder
impl !Send for AudioEncoder
impl !Sync for AudioEncoder
impl Unpin for AudioEncoder
impl UnsafeUnpin for AudioEncoder
impl UnwindSafe for AudioEncoder
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
Mutably borrows from an owned value. Read more