Struct Encoder

Source
pub struct Encoder { /* private fields */ }
Expand description

MPEG video recorder.

Implementations§

Source§

impl Encoder

Source

pub fn new<P: AsRef<Path>>(path: P, width: usize, height: usize) -> Encoder

Creates a new video recorder.

§Arguments:
  • path - path to the output file.
  • width - width of the recorded video.
  • height - height of the recorded video.
Source

pub fn new_with_params<P: AsRef<Path>>( path: P, width: usize, height: usize, bit_rate: Option<usize>, time_base: Option<(usize, usize)>, gop_size: Option<usize>, max_b_frames: Option<usize>, pix_fmt: Option<AVPixelFormat>, ) -> Encoder

Creates a new video recorder with custom recording parameters.

§Arguments:
  • path - path to the output file.
  • width - width of the recorded video.
  • height - height of the recorded video.
  • bit_rate - the average bit rate. Default value: 400000.
  • time_base - this is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented. Default value: (1, 60), i-e, 60fps.
  • gop_size - the number of pictures in a group of pictures. Default value: 10.
  • max_b_frames - maximum number of B-frames between non-B-frames. Default value: 1.
  • pix_fmt - pixel format. Default value: AVPixelFormat::PIX_FMT_YUV420P.
Source

pub fn encode_rgb( &mut self, width: usize, height: usize, data: &[u8], vertical_flip: bool, )

Adds a image with a RGB pixel format to the video.

Source

pub fn encode_rgba( &mut self, width: usize, height: usize, data: &[u8], vertical_flip: bool, )

Adds a image with a RGBA pixel format to the video.

Source

pub fn init(&mut self)

Initializes the recorder if needed.

This is automatically called when the first snapshot is made. Call this explicitly if you do not want the extra time overhead when the first snapshot is made.

Trait Implementations§

Source§

impl Drop for Encoder

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.