Video writer class. More...
#include <videoio.hpp>
Public Member Functions | |
CV_WRAP | VideoWriter () |
Default constructors. | |
CV_WRAP | VideoWriter (const String &filename, int fourcc, double fps, Size frameSize, bool isColor=true) |
CV_WRAP | VideoWriter (const String &filename, int apiPreference, int fourcc, double fps, Size frameSize, bool isColor=true) |
CV_WRAP | VideoWriter (const String &filename, int fourcc, double fps, const Size &frameSize, const std::vector< int > ¶ms) |
CV_WRAP | VideoWriter (const String &filename, int apiPreference, int fourcc, double fps, const Size &frameSize, const std::vector< int > ¶ms) |
virtual | ~VideoWriter () |
Default destructor. | |
virtual CV_WRAP bool | open (const String &filename, int fourcc, double fps, Size frameSize, bool isColor=true) |
Initializes or reinitializes video writer. | |
CV_WRAP bool | open (const String &filename, int apiPreference, int fourcc, double fps, Size frameSize, bool isColor=true) |
CV_WRAP bool | open (const String &filename, int fourcc, double fps, const Size &frameSize, const std::vector< int > ¶ms) |
CV_WRAP bool | open (const String &filename, int apiPreference, int fourcc, double fps, const Size &frameSize, const std::vector< int > ¶ms) |
virtual CV_WRAP bool | isOpened () const |
Returns true if video writer has been successfully initialized. | |
virtual CV_WRAP void | release () |
Closes the video writer. | |
virtual VideoWriter & | operator<< (const Mat &image) |
Stream operator to write the next video frame. | |
virtual VideoWriter & | operator<< (const UMat &image) |
virtual CV_WRAP void | write (InputArray image) |
Writes the next video frame. | |
virtual CV_WRAP bool | set (int propId, double value) |
Sets a property in the VideoWriter. | |
virtual CV_WRAP double | get (int propId) const |
Returns the specified VideoWriter property. | |
CV_WRAP String | getBackendName () const |
Returns used backend API name. | |
Static Public Member Functions | |
static CV_WRAP int | fourcc (char c1, char c2, char c3, char c4) |
Concatenates 4 chars to a fourcc code. | |
Static Protected Member Functions | |
static Ptr< IVideoWriter > | create (const String &filename, int fourcc, double fps, Size frameSize, bool isColor=true) |
Protected Attributes | |
Ptr< CvVideoWriter > | writer |
Ptr< IVideoWriter > | iwriter |
Video writer class.
The class provides C++ API for writing video files or image sequences.
CV_WRAP cv::VideoWriter::VideoWriter | ( | ) |
Default constructors.
The constructors/functions initialize video writers.
CV_WRAP cv::VideoWriter::VideoWriter | ( | const String & | filename, |
int | fourcc, | ||
double | fps, | ||
Size | frameSize, | ||
bool | isColor = true |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
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. |
Tips:
fourcc=-1
pops up the codec selection dialog from the system.img_%02d.jpg
) and fourcc=0
OR fps=0
. Use uncompressed image format (eg. img_%02d.BMP
) to save raw frames.codec=0; fps=0;
you can create an uncompressed (raw) video file.CV_WRAP cv::VideoWriter::VideoWriter | ( | const String & | filename, |
int | apiPreference, | ||
int | fourcc, | ||
double | fps, | ||
Size | frameSize, | ||
bool | isColor = true |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. 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.
CV_WRAP cv::VideoWriter::VideoWriter | ( | const String & | filename, |
int | fourcc, | ||
double | fps, | ||
const Size & | frameSize, | ||
const std::vector< int > & | params | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. The params
parameter allows to specify extra encoder parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) see cv::VideoWriterProperties
CV_WRAP cv::VideoWriter::VideoWriter | ( | const String & | filename, |
int | apiPreference, | ||
int | fourcc, | ||
double | fps, | ||
const Size & | frameSize, | ||
const std::vector< int > & | params | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
virtual |
Default destructor.
The method first calls VideoWriter::release to close the already opened file.
|
staticprotected |
|
static |
Concatenates 4 chars to a fourcc code.
This static method constructs the fourcc code of the codec to be used in the constructor VideoWriter::VideoWriter or VideoWriter::open.
|
virtual |
Returns the specified VideoWriter property.
propId | Property identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY) or one of Additional flags for video I/O API backends |
Returns used backend API name.
|
virtual |
Returns true if video writer has been successfully initialized.
CV_WRAP bool cv::VideoWriter::open | ( | const String & | filename, |
int | apiPreference, | ||
int | fourcc, | ||
double | fps, | ||
const Size & | frameSize, | ||
const std::vector< int > & | params | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
CV_WRAP bool cv::VideoWriter::open | ( | const String & | filename, |
int | apiPreference, | ||
int | fourcc, | ||
double | fps, | ||
Size | frameSize, | ||
bool | isColor = true |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
CV_WRAP bool cv::VideoWriter::open | ( | const String & | filename, |
int | fourcc, | ||
double | fps, | ||
const Size & | frameSize, | ||
const std::vector< int > & | params | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
virtual |
Initializes or reinitializes video writer.
The method opens video writer. Parameters are the same as in the constructor VideoWriter::VideoWriter.
true
if video writer has been successfully initializedThe method first calls VideoWriter::release to close the already opened file.
|
virtual |
Stream operator to write the next video frame.
|
virtual |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
virtual |
Closes the video writer.
The method is automatically called by subsequent VideoWriter::open and by the VideoWriter destructor.
|
virtual |
Sets a property in the VideoWriter.
propId | Property identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY) or one of Additional flags for video I/O API backends |
value | Value of the property. |
true
if the property is supported by the backend used by the VideoWriter instance.
|
virtual |
Writes the next video frame.
image | The written frame. In general, color images are expected in BGR format. |
The function/method writes the specified image to video file. It must have the same size as has been specified when opening the video writer.
|
protected |
|
protected |