pub struct AudioExtractor { /* private fields */ }Expand description
Demux an audio track from a media file and write it to a standalone audio file.
The audio bitstream is stream-copied (no decode/encode cycle). By default
the first audio stream is selected; call stream_index
to pick a specific one.
Returns EncodeError::MediaOperationFailed when:
- no audio stream is found (or
stream_indexpoints to a non-audio stream), or - the audio codec is incompatible with the output container.
§Example
ⓘ
use ff_encode::AudioExtractor;
AudioExtractor::new("source.mp4", "audio.mp3").run()?;Implementations§
Source§impl AudioExtractor
impl AudioExtractor
Sourcepub fn new(input: impl Into<PathBuf>, output: impl Into<PathBuf>) -> Self
pub fn new(input: impl Into<PathBuf>, output: impl Into<PathBuf>) -> Self
Create a new AudioExtractor.
input— source media file.output— destination audio file (format auto-detected from extension).
Sourcepub fn stream_index(self, idx: usize) -> Self
pub fn stream_index(self, idx: usize) -> Self
Select a specific audio stream by index (0-based over all streams in the container). Defaults to the first audio stream when not set.
Sourcepub fn run(self) -> Result<(), EncodeError>
pub fn run(self) -> Result<(), EncodeError>
Execute the audio extraction operation.
§Errors
EncodeError::MediaOperationFailedif no audio stream is found, the requested stream index is invalid or not audio, or the codec is incompatible with the output container.EncodeError::Ffmpegif any FFmpeg API call fails.
Auto Trait Implementations§
impl Freeze for AudioExtractor
impl RefUnwindSafe for AudioExtractor
impl Send for AudioExtractor
impl Sync for AudioExtractor
impl Unpin for AudioExtractor
impl UnsafeUnpin for AudioExtractor
impl UnwindSafe for AudioExtractor
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