pub struct Transcoder<'a> { /* private fields */ }Expand description
Builder for audio transcoding operations.
Obtained via Transcoder::new. Configure the target format,
bitrate, and optional time range, then call run
to produce the output file.
Implementations§
Source§impl<'a> Transcoder<'a>
impl<'a> Transcoder<'a>
Sourcepub fn new(unbundler: &'a mut MediaFile) -> Self
pub fn new(unbundler: &'a mut MediaFile) -> Self
Create a new transcoder for the given unbundler.
The default output format is WAV.
Sourcepub fn format(self, format: AudioFormat) -> Self
pub fn format(self, format: AudioFormat) -> Self
Set the target audio format.
Sourcepub fn with_format(self, format: AudioFormat) -> Self
pub fn with_format(self, format: AudioFormat) -> Self
Set the target audio format.
Alias for format.
Sourcepub fn start(self, start: Duration) -> Self
pub fn start(self, start: Duration) -> Self
Set an optional start time for the transcoded range.
Sourcepub fn with_start(self, start: Duration) -> Self
pub fn with_start(self, start: Duration) -> Self
Set an optional start time for the transcoded range.
Alias for start.
Sourcepub fn with_end(self, end: Duration) -> Self
pub fn with_end(self, end: Duration) -> Self
Set an optional end time for the transcoded range.
Alias for end.
Sourcepub fn bitrate(self, bitrate: usize) -> Self
pub fn bitrate(self, bitrate: usize) -> Self
Set the target bitrate in bits per second. If not set, the encoder default is used.
Sourcepub fn with_bitrate(self, bitrate: usize) -> Self
pub fn with_bitrate(self, bitrate: usize) -> Self
Set the target bitrate in bits per second.
Alias for bitrate.
Sourcepub fn run<P: AsRef<Path>>(self, path: P) -> Result<(), UnbundleError>
pub fn run<P: AsRef<Path>>(self, path: P) -> Result<(), UnbundleError>
Run the transcode and write the output to path.
This delegates to AudioHandle::save_range (or save) under
the hood: the audio is decoded and re-encoded to the target format.
§Errors
UnbundleError::NoAudioStreamif no audio stream exists.UnbundleError::TranscodeErrorif encoding fails.
Sourcepub fn run_to_memory(self) -> Result<Vec<u8>, UnbundleError>
pub fn run_to_memory(self) -> Result<Vec<u8>, UnbundleError>
Auto Trait Implementations§
impl<'a> Freeze for Transcoder<'a>
impl<'a> RefUnwindSafe for Transcoder<'a>
impl<'a> Send for Transcoder<'a>
impl<'a> !Sync for Transcoder<'a>
impl<'a> Unpin for Transcoder<'a>
impl<'a> UnsafeUnpin for Transcoder<'a>
impl<'a> !UnwindSafe for Transcoder<'a>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more