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
impl VideoWriter
Sourcepub fn default() -> Result<VideoWriter>
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.
Sourcepub fn new(
filename: &str,
fourcc: i32,
fps: f64,
frame_size: Size,
is_color: bool,
) -> Result<VideoWriter>
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 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=-1pops up the codec selection dialog from the system. - To save image sequence use a proper filename (eg.
img_%02d.jpg) andfourcc=0ORfps=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. - If FFMPEG is used, we allow frames of odd width or height, but in this case we truncate the rightmost column/the bottom row. Probably, this should be handled more elegantly, but some internal functions inside FFMPEG swscale require even width/height.
§C++ default parameters
- is_color: true
Sourcepub fn new_def(
filename: &str,
fourcc: i32,
fps: f64,
frame_size: Size,
) -> Result<VideoWriter>
pub fn new_def( filename: &str, fourcc: i32, fps: f64, frame_size: Size, ) -> 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 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=-1pops up the codec selection dialog from the system. - To save image sequence use a proper filename (eg.
img_%02d.jpg) andfourcc=0ORfps=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. - If FFMPEG is used, we allow frames of odd width or height, but in this case we truncate the rightmost column/the bottom row. Probably, this should be handled more elegantly, but some internal functions inside FFMPEG swscale require even width/height.
§Note
This alternative version of [new] function uses the following default values for its arguments:
- is_color: true
Sourcepub fn new_with_backend(
filename: &str,
api_preference: i32,
fourcc: i32,
fps: f64,
frame_size: Size,
is_color: bool,
) -> Result<VideoWriter>
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
Sourcepub fn new_with_backend_def(
filename: &str,
api_preference: i32,
fourcc: i32,
fps: f64,
frame_size: Size,
) -> Result<VideoWriter>
pub fn new_with_backend_def( filename: &str, api_preference: i32, fourcc: i32, fps: f64, frame_size: Size, ) -> 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.
§Note
This alternative version of [new_with_backend] function uses the following default values for its arguments:
- is_color: true
Sourcepub fn new_1(
filename: &str,
fourcc: i32,
fps: f64,
frame_size: Size,
params: &Vector<i32>,
) -> Result<VideoWriter>
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
Sourcepub fn new_2(
filename: &str,
api_preference: i32,
fourcc: i32,
fps: f64,
frame_size: Size,
params: &Vector<i32>,
) -> Result<VideoWriter>
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
Trait Implementations§
Source§impl Boxed for VideoWriter
impl Boxed for VideoWriter
Source§unsafe fn from_raw(
ptr: <VideoWriter as OpenCVFromExtern>::ExternReceive,
) -> Self
unsafe fn from_raw( ptr: <VideoWriter as OpenCVFromExtern>::ExternReceive, ) -> Self
Source§fn into_raw(self) -> <VideoWriter as OpenCVTypeExternContainer>::ExternSendMut
fn into_raw(self) -> <VideoWriter as OpenCVTypeExternContainer>::ExternSendMut
Source§fn as_raw(&self) -> <VideoWriter as OpenCVTypeExternContainer>::ExternSend
fn as_raw(&self) -> <VideoWriter as OpenCVTypeExternContainer>::ExternSend
Source§fn as_raw_mut(
&mut self,
) -> <VideoWriter as OpenCVTypeExternContainer>::ExternSendMut
fn as_raw_mut( &mut self, ) -> <VideoWriter as OpenCVTypeExternContainer>::ExternSendMut
Source§impl Debug for VideoWriter
impl Debug for VideoWriter
Source§impl Drop for VideoWriter
impl Drop for VideoWriter
Source§impl VideoWriterTrait for VideoWriter
impl VideoWriterTrait for VideoWriter
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>
fn open( &mut self, filename: &str, fourcc: i32, fps: f64, frame_size: Size, is_color: bool, ) -> Result<bool>
Source§fn open_def(
&mut self,
filename: &str,
fourcc: i32,
fps: f64,
frame_size: Size,
) -> Result<bool>
fn open_def( &mut self, filename: &str, fourcc: i32, fps: f64, frame_size: Size, ) -> Result<bool>
Source§fn open_with_backend(
&mut self,
filename: &str,
api_preference: i32,
fourcc: i32,
fps: f64,
frame_size: Size,
is_color: bool,
) -> Result<bool>
fn open_with_backend( &mut self, filename: &str, api_preference: i32, fourcc: i32, fps: f64, frame_size: Size, is_color: bool, ) -> Result<bool>
Source§fn open_with_backend_def(
&mut self,
filename: &str,
api_preference: i32,
fourcc: i32,
fps: f64,
frame_size: Size,
) -> Result<bool>
fn open_with_backend_def( &mut self, filename: &str, api_preference: i32, fourcc: i32, fps: f64, frame_size: Size, ) -> Result<bool>
Source§fn open_1(
&mut self,
filename: &str,
fourcc: i32,
fps: f64,
frame_size: Size,
params: &Vector<i32>,
) -> Result<bool>
fn open_1( &mut self, filename: &str, fourcc: i32, fps: f64, frame_size: Size, params: &Vector<i32>, ) -> Result<bool>
Source§fn open_2(
&mut self,
filename: &str,
api_preference: i32,
fourcc: i32,
fps: f64,
frame_size: Size,
params: &Vector<i32>,
) -> Result<bool>
fn open_2( &mut self, filename: &str, api_preference: i32, fourcc: i32, fps: f64, frame_size: Size, params: &Vector<i32>, ) -> Result<bool>
Source§impl VideoWriterTraitConst for VideoWriter
impl VideoWriterTraitConst for VideoWriter
impl Send for VideoWriter
Auto Trait Implementations§
impl Freeze for VideoWriter
impl RefUnwindSafe for VideoWriter
impl !Sync for VideoWriter
impl Unpin for VideoWriter
impl UnwindSafe for VideoWriter
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<Mat> ModifyInplace for Matwhere
Mat: Boxed,
impl<Mat> ModifyInplace for Matwhere
Mat: Boxed,
Source§unsafe fn modify_inplace<Res>(
&mut self,
f: impl FnOnce(&Mat, &mut Mat) -> Res,
) -> Res
unsafe fn modify_inplace<Res>( &mut self, f: impl FnOnce(&Mat, &mut Mat) -> Res, ) -> Res
Mat or another similar object. By passing
a mutable reference to the Mat to this function your closure will get called with the read reference and a write references
to the same Mat. This is unsafe in a general case as it leads to having non-exclusive mutable access to the internal data,
but it can be useful for some performance sensitive operations. One example of an OpenCV function that allows such in-place
modification is imgproc::threshold. Read more