§ VideoWriter() [2/3]
cv::VideoWriter::VideoWriter | ( | const String & | filename, |
int | fourcc, | ||
double | fps, | ||
Size | frameSize, | ||
bool | isColor = true | ||
) |
ParametersThis 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 Video Codecs by FOURCC page. 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 (the flag is currently supported on Windows only). |
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
) andfourcc=0
ORfps=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.