Class VideoWriter
AVI Video File Writer
Implements
Inherited Members
Namespace: OpenCvSharp
Assembly: OpenCvSharp.dll
Syntax
public class VideoWriter : DisposableCvObject, ICvPtrHolder
Constructors
| Improve this Doc View SourceVideoWriter()
Declaration
public VideoWriter()
VideoWriter(String, FourCC, Double, Size, VideoWriterPara)
Creates video writer structure.
Declaration
public VideoWriter(string fileName, FourCC fourcc, double fps, Size frameSize, VideoWriterPara prms)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | Name of the output video file. |
FourCC | fourcc | 4-character code of codec used to compress the frames. For example, "PIM1" is MPEG-1 codec, "MJPG" is motion-jpeg codec etc. Under Win32 it is possible to pass null in order to choose compression method and additional compression parameters from dialog. |
System.Double | fps | Frame rate of the created video stream. |
OpenCvSharp.Size | frameSize | Size of video frames. |
VideoWriterPara | prms | Parameters of VideoWriter for hardware acceleration |
VideoWriter(String, FourCC, Double, Size, Boolean)
Creates video writer structure.
Declaration
public VideoWriter(string fileName, FourCC fourcc, double fps, Size frameSize, bool isColor = true)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | Name of the output video file. |
FourCC | fourcc | 4-character code of codec used to compress the frames. For example, "PIM1" is MPEG-1 codec, "MJPG" is motion-jpeg codec etc. Under Win32 it is possible to pass null in order to choose compression method and additional compression parameters from dialog. |
System.Double | fps | Frame rate of the created video stream. |
OpenCvSharp.Size | frameSize | Size of video frames. |
System.Boolean | isColor | If it is true, the encoder will expect and encode color frames, otherwise it will work with grayscale frames (the flag is currently supported on Windows only). |
VideoWriter(String, FourCC, Double, Size, Int32[])
Creates video writer structure.
Declaration
public VideoWriter(string fileName, FourCC fourcc, double fps, Size frameSize, int[] prms)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | Name of the output video file. |
FourCC | fourcc | 4-character code of codec used to compress the frames. For example, "PIM1" is MPEG-1 codec, "MJPG" is motion-jpeg codec etc. Under Win32 it is possible to pass null in order to choose compression method and additional compression parameters from dialog. |
System.Double | fps | Frame rate of the created video stream. |
OpenCvSharp.Size | frameSize | Size of video frames. |
System.Int32[] | prms | The |
VideoWriter(String, VideoCaptureAPIs, FourCC, Double, Size, VideoWriterPara)
Creates video writer structure.
Declaration
public VideoWriter(string fileName, VideoCaptureAPIs apiPreference, FourCC fourcc, double fps, Size frameSize, VideoWriterPara prms)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | Name of the output video file. |
VideoCaptureAPIs | apiPreference | 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. |
FourCC | fourcc | 4-character code of codec used to compress the frames. For example, "PIM1" is MPEG-1 codec, "MJPG" is motion-jpeg codec etc. Under Win32 it is possible to pass null in order to choose compression method and additional compression parameters from dialog. |
System.Double | fps | Frame rate of the created video stream. |
OpenCvSharp.Size | frameSize | Size of video frames. |
VideoWriterPara | prms | Parameters of VideoWriter for hardware acceleration |
VideoWriter(String, VideoCaptureAPIs, FourCC, Double, Size, Boolean)
Creates video writer structure.
Declaration
public VideoWriter(string fileName, VideoCaptureAPIs apiPreference, FourCC fourcc, double fps, Size frameSize, bool isColor = true)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | Name of the output video file. |
VideoCaptureAPIs | apiPreference | 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. |
FourCC | fourcc | 4-character code of codec used to compress the frames. For example, "PIM1" is MPEG-1 codec, "MJPG" is motion-jpeg codec etc. Under Win32 it is possible to pass null in order to choose compression method and additional compression parameters from dialog. |
System.Double | fps | Frame rate of the created video stream. |
OpenCvSharp.Size | frameSize | Size of video frames. |
System.Boolean | isColor | If it is true, the encoder will expect and encode color frames, otherwise it will work with grayscale frames (the flag is currently supported on Windows only). |
VideoWriter(String, VideoCaptureAPIs, FourCC, Double, Size, Int32[])
Creates video writer structure.
Declaration
public VideoWriter(string fileName, VideoCaptureAPIs apiPreference, FourCC fourcc, double fps, Size frameSize, int[] prms)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | Name of the output video file. |
VideoCaptureAPIs | apiPreference | 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. |
FourCC | fourcc | 4-character code of codec used to compress the frames. For example, "PIM1" is MPEG-1 codec, "MJPG" is motion-jpeg codec etc. Under Win32 it is possible to pass null in order to choose compression method and additional compression parameters from dialog. |
System.Double | fps | Frame rate of the created video stream. |
OpenCvSharp.Size | frameSize | Size of video frames. |
System.Int32[] | prms | The |
Properties
| Improve this Doc View SourceFileName
Get output video file name
Declaration
public string FileName { get; }
Property Value
Type | Description |
---|---|
System.String |
Fps
Frames per second of the output video
Declaration
public double Fps { get; }
Property Value
Type | Description |
---|---|
System.Double |
FrameSize
Get size of frame image
Declaration
public Size FrameSize { get; }
Property Value
Type | Description |
---|---|
OpenCvSharp.Size |
IsColor
Get whether output frames is color or not
Declaration
public bool IsColor { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceDisposeUnmanaged()
Releases unmanaged resources
Declaration
protected override void DisposeUnmanaged()
Overrides
| Improve this Doc View SourceFourCC(Char, Char, Char, Char)
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.
Declaration
public static int FourCC(char c1, char c2, char c3, char c4)
Parameters
Type | Name | Description |
---|---|---|
System.Char | c1 | |
System.Char | c2 | |
System.Char | c3 | |
System.Char | c4 |
Returns
Type | Description |
---|---|
System.Int32 |
FourCC(String)
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.
Declaration
public static int FourCC(string code)
Parameters
Type | Name | Description |
---|---|---|
System.String | code |
Returns
Type | Description |
---|---|
System.Int32 |
Get(VideoWriterProperties)
Returns the specified VideoWriter property
Declaration
public double Get(VideoWriterProperties propId)
Parameters
Type | Name | Description |
---|---|---|
VideoWriterProperties | propId | Property identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY) or one of @ref videoio_flags_others |
Returns
Type | Description |
---|---|
System.Double | Value for the specified property. Value 0 is returned when querying a property that is not supported by the backend used by the VideoWriter instance. |
GetBackendName()
Returns used backend API name. Note that stream should be opened.
Declaration
public string GetBackendName()
Returns
Type | Description |
---|---|
System.String |
IsOpened()
Returns true if video writer has been successfully initialized.
Declaration
public bool IsOpened()
Returns
Type | Description |
---|---|
System.Boolean |
Open(String, FourCC, Double, Size, Boolean)
Creates video writer structure.
Declaration
public bool Open(string fileName, FourCC fourcc, double fps, Size frameSize, bool isColor = true)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | Name of the output video file. |
FourCC | fourcc | 4-character code of codec used to compress the frames. For example, "PIM1" is MPEG-1 codec, "MJPG" is motion-jpeg codec etc. Under Win32 it is possible to pass null in order to choose compression method and additional compression parameters from dialog. |
System.Double | fps | Frame rate of the created video stream. |
OpenCvSharp.Size | frameSize | Size of video frames. |
System.Boolean | isColor | If it is true, the encoder will expect and encode color frames, otherwise it will work with grayscale frames (the flag is currently supported on Windows only). |
Returns
Type | Description |
---|---|
System.Boolean |
Open(String, VideoCaptureAPIs, FourCC, Double, Size, Boolean)
Creates video writer structure.
Declaration
public bool Open(string fileName, VideoCaptureAPIs apiPreference, FourCC fourcc, double fps, Size frameSize, bool isColor = true)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | Name of the output video file. |
VideoCaptureAPIs | apiPreference | 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. |
FourCC | fourcc | 4-character code of codec used to compress the frames. For example, "PIM1" is MPEG-1 codec, "MJPG" is motion-jpeg codec etc. Under Win32 it is possible to pass null in order to choose compression method and additional compression parameters from dialog. |
System.Double | fps | Frame rate of the created video stream. |
OpenCvSharp.Size | frameSize | Size of video frames. |
System.Boolean | isColor | If it is true, the encoder will expect and encode color frames, otherwise it will work with grayscale frames (the flag is currently supported on Windows only). |
Returns
Type | Description |
---|---|
System.Boolean |
Release()
Declaration
public void Release()
Set(VideoWriterProperties, Double)
Sets a property in the VideoWriter.
Declaration
public bool Set(VideoWriterProperties propId, double value)
Parameters
Type | Name | Description |
---|---|---|
VideoWriterProperties | propId | Property identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY) or one of @ref videoio_flags_others |
System.Double | value | Value of the property. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Write(InputArray)
Writes/appends one frame to video file.
Declaration
public void Write(InputArray image)
Parameters
Type | Name | Description |
---|---|---|
InputArray | image | the written frame. |