pub struct VideoEncoder { /* private fields */ }Expand description
Encodes video (and optionally audio) frames to a file using FFmpeg.
§Construction
Use VideoEncoder::create() to get a VideoEncoderBuilder, then call
VideoEncoderBuilder::build():
use ff_encode::{VideoEncoder, VideoCodec};
let mut encoder = VideoEncoder::create("output.mp4")
.video(1920, 1080, 30.0)
.video_codec(VideoCodec::H264)
.build()?;Implementations§
Source§impl VideoEncoder
impl VideoEncoder
Sourcepub fn create<P: AsRef<Path>>(path: P) -> VideoEncoderBuilder
pub fn create<P: AsRef<Path>>(path: P) -> VideoEncoderBuilder
Creates a builder for the specified output file path.
This method is infallible. Validation occurs when
VideoEncoderBuilder::build() is called.
Sourcepub fn actual_video_codec(&self) -> &str
pub fn actual_video_codec(&self) -> &str
Returns the name of the FFmpeg encoder actually used (e.g. "h264_nvenc", "libx264").
Sourcepub fn actual_audio_codec(&self) -> &str
pub fn actual_audio_codec(&self) -> &str
Returns the name of the FFmpeg audio encoder actually used.
Sourcepub fn hardware_encoder(&self) -> HardwareEncoder
pub fn hardware_encoder(&self) -> HardwareEncoder
Returns the hardware encoder actually in use.
Sourcepub fn is_hardware_encoding(&self) -> bool
pub fn is_hardware_encoding(&self) -> bool
Returns true if a hardware encoder is active.
Sourcepub fn is_lgpl_compliant(&self) -> bool
pub fn is_lgpl_compliant(&self) -> bool
Returns true if the selected encoder is LGPL-compatible (safe for commercial use).
Sourcepub fn push_video(&mut self, frame: &VideoFrame) -> Result<(), EncodeError>
pub fn push_video(&mut self, frame: &VideoFrame) -> Result<(), EncodeError>
Pushes a video frame for encoding.
§Errors
Returns EncodeError if encoding fails or the encoder is not initialised.
Returns EncodeError::Cancelled if the progress callback requested cancellation.
Sourcepub fn push_audio(&mut self, frame: &AudioFrame) -> Result<(), EncodeError>
pub fn push_audio(&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.