pub struct AudioAdder { /* private fields */ }Expand description
Mux an audio track into a silent (or existing) video file.
The video bitstream is stream-copied (no decode/encode cycle). When the
audio source is shorter than the video and loop_audio
has been called, the audio is looped by re-seeking and advancing the PTS
offset until the video is exhausted.
Returns EncodeError::MediaOperationFailed when no video stream is found
in video_input or no audio stream is found in audio_input.
§Example
ⓘ
use ff_encode::AudioAdder;
AudioAdder::new("silent.mp4", "soundtrack.mp3", "output.mp4")
.loop_audio()
.run()?;Implementations§
Source§impl AudioAdder
impl AudioAdder
Sourcepub fn new(
video_input: impl Into<PathBuf>,
audio_input: impl Into<PathBuf>,
output: impl Into<PathBuf>,
) -> Self
pub fn new( video_input: impl Into<PathBuf>, audio_input: impl Into<PathBuf>, output: impl Into<PathBuf>, ) -> Self
Create a new AudioAdder.
video_input— source file whose video stream is kept.audio_input— source file whose first audio stream is used.output— path for the combined output file.
Sourcepub fn loop_audio(self) -> Self
pub fn loop_audio(self) -> Self
Loop the audio when it is shorter than the video.
The audio is re-seeked to the start and the PTS offset is advanced each time the audio stream is exhausted, until the video ends.
Sourcepub fn run(self) -> Result<(), EncodeError>
pub fn run(self) -> Result<(), EncodeError>
Execute the audio addition operation.
§Errors
EncodeError::MediaOperationFailedifvideo_inputhas no video stream oraudio_inputhas no audio stream.EncodeError::Ffmpegif any FFmpeg API call fails.
Auto Trait Implementations§
impl Freeze for AudioAdder
impl RefUnwindSafe for AudioAdder
impl Send for AudioAdder
impl Sync for AudioAdder
impl Unpin for AudioAdder
impl UnsafeUnpin for AudioAdder
impl UnwindSafe for AudioAdder
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