Class VideoWriter
Create a video writer that write images to video format
public class VideoWriter : UnmanagedObject, IDisposable
- Inheritance
-
VideoWriter
- Implements
- Inherited Members
Constructors
VideoWriter(string, int, double, Size, bool)
Create a video writer using the specific information
public VideoWriter(string fileName, int compressionCode, double fps, Size size, bool isColor)
Parameters
fileName
stringThe name of the video file to be written to
compressionCode
intCompression code. Usually computed using CvInvoke.CV_FOURCC. On windows use -1 to open a codec selection dialog. On Linux, use CvInvoke.CV_FOURCC('I', 'Y', 'U', 'V') for default codec for the specific file name.
fps
doubleframe rate per second
size
Sizethe size of the frame
isColor
booltrue if this is a color video, false otherwise
VideoWriter(string, int, Size, bool)
Create a video writer using the specific information. On windows, it will open a codec selection dialog. On linux, it will use the default codec for the specified filename
public VideoWriter(string fileName, int fps, Size size, bool isColor)
Parameters
fileName
stringThe name of the video file to be written to
fps
intframe rate per second
size
Sizethe size of the frame
isColor
booltrue if this is a color video, false otherwise
VideoWriter(string, int, int, double, Size, bool)
Create a video writer using the specific information
public VideoWriter(string fileName, int apiPreference, int compressionCode, double fps, Size size, bool isColor)
Parameters
fileName
stringThe name of the video file to be written to
apiPreference
intAllows to specify API backends to use. Use 0 if you don't have any preference.
compressionCode
intCompression code. Usually computed using CvInvoke.CV_FOURCC. On windows use -1 to open a codec selection dialog. On Linux, use CvInvoke.CV_FOURCC('I', 'Y', 'U', 'V') for default codec for the specific file name.
fps
doubleframe rate per second
size
Sizethe size of the frame
isColor
booltrue if this is a color video, false otherwise
VideoWriter(string, int, int, double, Size, params Tuple<WriterProperty, int>[])
Create a video writer using the specific information
public VideoWriter(string fileName, int apiPreference, int compressionCode, double fps, Size size, params Tuple<VideoWriter.WriterProperty, int>[] writerProperties)
Parameters
fileName
stringThe name of the video file to be written to
apiPreference
intAllows to specify API backends to use. Use 0 if you don't have any specific preference.
compressionCode
intCompression code. Usually computed using CvInvoke.CV_FOURCC. On windows use -1 to open a codec selection dialog. On Linux, use VideoWriter.Fourcc('I', 'Y', 'U', 'V') for default codec for the specific file name.
fps
doubleFrame rate per second
size
SizeThe size of the frame
writerProperties
Tuple<WriterProperty, int>[]Optional writer properties. e.g. new Tuple<VideoWriter.WriterProperty>(VideoWriter.WriterProperty.HwAcceleration, (int) VideoAccelerationType.Any)
Properties
BackendName
The name of the backend used by this VideoWriter
public string BackendName { get; }
Property Value
IsOpened
Returns true if video writer has been successfully initialized.
public bool IsOpened { get; }
Property Value
Methods
DisposeObject()
Release the video writer and all the memory associate with it
protected override void DisposeObject()
Fourcc(char, char, char, char)
Generate 4-character code of codec used to compress the frames. For example, CV_FOURCC('P','I','M','1') is MPEG-1 codec, CV_FOURCC('M','J','P','G') is motion-jpeg codec etc.
public static int Fourcc(char c1, char c2, char c3, char c4)
Parameters
Returns
- int
The integer value calculated from the four cc code
Get(WriterProperty)
Returns the specified VideoWriter property.
public double Get(VideoWriter.WriterProperty prop)
Parameters
prop
VideoWriter.WriterPropertyProperty identifier.
Returns
- double
The value of the specific property
Set(WriterProperty, double)
Sets a property in the VideoWriter.
public bool Set(VideoWriter.WriterProperty prop, double value)
Parameters
prop
VideoWriter.WriterPropertyProperty identifier
value
doubleValue of the property.
Returns
- bool
The value of the specific property
Write(IInputArray)
Write a single frame to the video writer
public void Write(IInputArray frame)
Parameters
frame
IInputArrayThe frame to be written to the video writer