pub struct VideoEncoder { /* private fields */ }
Expand description
The VideoEncoder
struct is used to encode video frames and save them to a specified file path.
Implementationsยง
Sourceยงimpl VideoEncoder
impl VideoEncoder
Sourcepub fn new<P: AsRef<Path>>(
video_settings: VideoSettingsBuilder,
audio_settings: AudioSettingsBuilder,
container_settings: ContainerSettingsBuilder,
path: P,
) -> Result<Self, VideoEncoderError>
pub fn new<P: AsRef<Path>>( video_settings: VideoSettingsBuilder, audio_settings: AudioSettingsBuilder, container_settings: ContainerSettingsBuilder, path: P, ) -> Result<Self, VideoEncoderError>
Creates a new VideoEncoder
instance with the specified parameters.
ยงArguments
encoder_type
- The type of video encoder to use.encoder_quality
- The quality of the video encoder.width
- The width of the video frames.height
- The height of the video frames.path
- The file path where the encoded video will be saved.
ยงReturns
Returns a Result
containing the VideoEncoder
instance if successful, or a
VideoEncoderError
if an error occurs.
Sourcepub fn new_from_stream(
video_settings: VideoSettingsBuilder,
audio_settings: AudioSettingsBuilder,
container_settings: ContainerSettingsBuilder,
stream: IRandomAccessStream,
) -> Result<Self, VideoEncoderError>
pub fn new_from_stream( video_settings: VideoSettingsBuilder, audio_settings: AudioSettingsBuilder, container_settings: ContainerSettingsBuilder, stream: IRandomAccessStream, ) -> Result<Self, VideoEncoderError>
Creates a new VideoEncoder
instance with the specified parameters.
ยงArguments
encoder_type
- The type of video encoder to use.encoder_quality
- The quality of the video encoder.width
- The width of the video frames.height
- The height of the video frames.stream
- The stream where the encoded video will be saved.
ยงReturns
Returns a Result
containing the VideoEncoder
instance if successful, or a
VideoEncoderError
if an error occurs.
Sourcepub fn send_frame(
&mut self,
frame: &mut Frame<'_>,
) -> Result<(), VideoEncoderError>
pub fn send_frame( &mut self, frame: &mut Frame<'_>, ) -> Result<(), VideoEncoderError>
Sourcepub fn send_frame_with_audio(
&mut self,
frame: &mut Frame<'_>,
audio_buffer: &[u8],
) -> Result<(), VideoEncoderError>
pub fn send_frame_with_audio( &mut self, frame: &mut Frame<'_>, audio_buffer: &[u8], ) -> Result<(), VideoEncoderError>
Sends a video frame with audio to the video encoder for encoding.
ยงArguments
frame
- A mutable reference to theFrame
to be encoded.audio_buffer
- A reference to the audio byte slice to be encoded.
ยงReturns
Returns Ok(())
if the frame is successfully sent for encoding, or a VideoEncoderError
if an error occurs.
Sourcepub fn send_frame_buffer(
&mut self,
buffer: &[u8],
timestamp: i64,
) -> Result<(), VideoEncoderError>
pub fn send_frame_buffer( &mut self, buffer: &[u8], timestamp: i64, ) -> Result<(), VideoEncoderError>
Sends a video frame to the video encoder for encoding.
ยงArguments
buffer
- A reference to the frame byte slice to be encoded. The Windows API expects this to be BGRA and bottom-to-top.timestamp
- The timestamp of the frame, in 100-nanosecond units.
ยงReturns
Returns Ok(())
if the frame is successfully sent for encoding, or a VideoEncoderError
if an error occurs.
Sourcepub fn send_audio_buffer(
&mut self,
buffer: &[u8],
timestamp: i64,
) -> Result<(), VideoEncoderError>
pub fn send_audio_buffer( &mut self, buffer: &[u8], timestamp: i64, ) -> Result<(), VideoEncoderError>
Sends a video audio to the video encoder for encoding.
ยงArguments
buffer
- A reference to the audio byte slice to be encoded.timestamp
- The timestamp of the audio buffer, in 100-nanosecond units.
ยงReturns
Returns Ok(())
if the frame is successfully sent for encoding, or a VideoEncoderError
if an error occurs.
Trait Implementationsยง
Sourceยงimpl Drop for VideoEncoder
impl Drop for VideoEncoder
impl Send for VideoEncoder
Auto Trait Implementationsยง
impl Freeze for VideoEncoder
impl !RefUnwindSafe for VideoEncoder
impl Sync for VideoEncoder
impl Unpin for VideoEncoder
impl !UnwindSafe for VideoEncoder
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