Struct opencv::videoio::VideoWriter

source ·
pub struct VideoWriter { /* private fields */ }
Expand description

Video writer class.

The class provides C++ API for writing video files or image sequences.

Implementations§

source§

impl VideoWriter

source

pub fn default() -> Result<VideoWriter>

Default constructors

The constructors/functions initialize video writers.

  • On Linux FFMPEG is used to write videos;
  • On Windows FFMPEG or MSWF or DSHOW is used;
  • On MacOSX AVFoundation is used.
source

pub fn new( filename: &str, fourcc: i32, fps: f64, frame_size: Size, is_color: bool ) -> Result<VideoWriter>

Default constructors

The constructors/functions initialize video writers.

  • On Linux FFMPEG is used to write videos;
  • On Windows FFMPEG or MSWF or DSHOW is used;
  • On MacOSX AVFoundation is used.
Overloaded parameters
Parameters
  • filename: Name of the output video file.

  • fourcc: 4-character code of codec used to compress the frames. For example, VideoWriter::fourcc(‘P’,‘I’,‘M’,‘1’) is a MPEG-1 codec, VideoWriter::fourcc(‘M’,‘J’,‘P’,‘G’) is a motion-jpeg codec etc. List of codes can be obtained at MSDN page or with this archived page of the fourcc site for a more complete list). FFMPEG backend with MP4 container natively uses other values as fourcc code: see ObjectType, so you may receive a warning message from OpenCV about fourcc code conversion.

  • fps: Framerate of the created video stream.

  • frameSize: Size of the video frames.

  • isColor: If it is not zero, the encoder will expect and encode color frames, otherwise it will work with grayscale frames.

    @b Tips:

    • With some backends fourcc=-1 pops up the codec selection dialog from the system.
    • To save image sequence use a proper filename (eg. img_%02d.jpg) and fourcc=0 OR fps=0. Use uncompressed image format (eg. img_%02d.BMP) to save raw frames.
    • Most codecs are lossy. If you want lossless video file you need to use a lossless codecs (eg. FFMPEG FFV1, Huffman HFYU, Lagarith LAGS, etc…)
    • If FFMPEG is enabled, using codec=0; fps=0; you can create an uncompressed (raw) video file.
C++ default parameters
  • is_color: true
source

pub fn new_def( filename: &str, fourcc: i32, fps: f64, frame_size: Size ) -> Result<VideoWriter>

@overload

Parameters
  • filename: Name of the output video file.
  • fourcc: 4-character code of codec used to compress the frames. For example, VideoWriter::fourcc(‘P’,‘I’,‘M’,‘1’) is a MPEG-1 codec, VideoWriter::fourcc(‘M’,‘J’,‘P’,‘G’) is a motion-jpeg codec etc. List of codes can be obtained at MSDN page or with this archived page of the fourcc site for a more complete list). FFMPEG backend with MP4 container natively uses other values as fourcc code: see ObjectType, so you may receive a warning message from OpenCV about fourcc code conversion.
  • fps: Framerate of the created video stream.
  • frameSize: Size of the video frames.
  • isColor: If it is not zero, the encoder will expect and encode color frames, otherwise it will work with grayscale frames.

@b Tips:

  • With some backends fourcc=-1 pops up the codec selection dialog from the system.
  • To save image sequence use a proper filename (eg. img_%02d.jpg) and fourcc=0 OR fps=0. Use uncompressed image format (eg. img_%02d.BMP) to save raw frames.
  • Most codecs are lossy. If you want lossless video file you need to use a lossless codecs (eg. FFMPEG FFV1, Huffman HFYU, Lagarith LAGS, etc…)
  • If FFMPEG is enabled, using codec=0; fps=0; you can create an uncompressed (raw) video file.
Note

This alternative version of [new] function uses the following default values for its arguments:

  • is_color: true
source

pub fn new_with_backend( filename: &str, api_preference: i32, fourcc: i32, fps: f64, frame_size: Size, is_color: bool ) -> Result<VideoWriter>

Default constructors

The constructors/functions initialize video writers.

  • On Linux FFMPEG is used to write videos;
  • On Windows FFMPEG or MSWF or DSHOW is used;
  • On MacOSX AVFoundation is used.
Overloaded parameters

The apiPreference parameter allows to specify API backends to use. Can be used to enforce a specific reader implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_GSTREAMER.

C++ default parameters
  • is_color: true
source

pub fn new_with_backend_def( filename: &str, api_preference: i32, fourcc: i32, fps: f64, frame_size: Size ) -> Result<VideoWriter>

@overload The apiPreference parameter allows to specify API backends to use. Can be used to enforce a specific reader implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_GSTREAMER.

Note

This alternative version of [new_with_backend] function uses the following default values for its arguments:

  • is_color: true
source

pub fn new_1( filename: &str, fourcc: i32, fps: f64, frame_size: Size, params: &Vector<i32> ) -> Result<VideoWriter>

Default constructors

The constructors/functions initialize video writers.

  • On Linux FFMPEG is used to write videos;
  • On Windows FFMPEG or MSWF or DSHOW is used;
  • On MacOSX AVFoundation is used.
Overloaded parameters
 * The `params` parameter allows to specify extra encoder parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .)
 * see cv::VideoWriterProperties
source

pub fn new_2( filename: &str, api_preference: i32, fourcc: i32, fps: f64, frame_size: Size, params: &Vector<i32> ) -> Result<VideoWriter>

Default constructors

The constructors/functions initialize video writers.

  • On Linux FFMPEG is used to write videos;
  • On Windows FFMPEG or MSWF or DSHOW is used;
  • On MacOSX AVFoundation is used.
Overloaded parameters
source

pub fn fourcc(c1: char, c2: char, c3: char, c4: char) -> Result<i32>

Concatenates 4 chars to a fourcc code

Returns

a fourcc code

This static method constructs the fourcc code of the codec to be used in the constructor VideoWriter::VideoWriter or VideoWriter::open.

Trait Implementations§

source§

impl Boxed for VideoWriter

source§

unsafe fn from_raw(ptr: *mut c_void) -> Self

Wrap the specified raw pointer Read more
source§

fn into_raw(self) -> *mut c_void

Return an the underlying raw pointer while consuming this wrapper. Read more
source§

fn as_raw(&self) -> *const c_void

Return the underlying raw pointer. Read more
source§

fn as_raw_mut(&mut self) -> *mut c_void

Return the underlying mutable raw pointer Read more
source§

impl Debug for VideoWriter

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for VideoWriter

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl VideoWriterTrait for VideoWriter

source§

fn as_raw_mut_VideoWriter(&mut self) -> *mut c_void

source§

fn open( &mut self, filename: &str, fourcc: i32, fps: f64, frame_size: Size, is_color: bool ) -> Result<bool>

Initializes or reinitializes video writer. Read more
source§

fn open_def( &mut self, filename: &str, fourcc: i32, fps: f64, frame_size: Size ) -> Result<bool>

Initializes or reinitializes video writer. Read more
source§

fn open_with_backend( &mut self, filename: &str, api_preference: i32, fourcc: i32, fps: f64, frame_size: Size, is_color: bool ) -> Result<bool>

Initializes or reinitializes video writer. Read more
source§

fn open_with_backend_def( &mut self, filename: &str, api_preference: i32, fourcc: i32, fps: f64, frame_size: Size ) -> Result<bool>

@overload Read more
source§

fn open_1( &mut self, filename: &str, fourcc: i32, fps: f64, frame_size: Size, params: &Vector<i32> ) -> Result<bool>

Initializes or reinitializes video writer. Read more
source§

fn open_2( &mut self, filename: &str, api_preference: i32, fourcc: i32, fps: f64, frame_size: Size, params: &Vector<i32> ) -> Result<bool>

Initializes or reinitializes video writer. Read more
source§

fn release(&mut self) -> Result<()>

Closes the video writer. Read more
source§

fn write(&mut self, image: &impl ToInputArray) -> Result<()>

Writes the next video frame Read more
source§

fn set(&mut self, prop_id: i32, value: f64) -> Result<bool>

Sets a property in the VideoWriter. Read more
source§

impl VideoWriterTraitConst for VideoWriter

source§

fn as_raw_VideoWriter(&self) -> *const c_void

source§

fn is_opened(&self) -> Result<bool>

Returns true if video writer has been successfully initialized.
source§

fn get(&self, prop_id: i32) -> Result<f64>

Returns the specified VideoWriter property Read more
source§

fn get_backend_name(&self) -> Result<String>

Returns used backend API name Read more
source§

impl Send for VideoWriter

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.