@Namespace(value="cv") @NoOffset @Properties(inherit=opencv_videoio.class) public class VideoWriter extends Pointer
The class provides C++ API for writing video files or image sequences.
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter
Constructor and Description |
---|
VideoWriter()
\brief Default constructors
|
VideoWriter(BytePointer filename,
int fourcc,
double fps,
Size frameSize) |
VideoWriter(BytePointer filename,
int fourcc,
double fps,
Size frameSize,
boolean isColor)
\overload
|
VideoWriter(BytePointer filename,
int apiPreference,
int fourcc,
double fps,
Size frameSize) |
VideoWriter(BytePointer filename,
int apiPreference,
int fourcc,
double fps,
Size frameSize,
boolean isColor)
\overload
The
apiPreference parameter allows to specify API backends to use. |
VideoWriter(long size)
Native array allocator.
|
VideoWriter(Pointer p)
Pointer cast constructor.
|
VideoWriter(String filename,
int fourcc,
double fps,
Size frameSize) |
VideoWriter(String filename,
int fourcc,
double fps,
Size frameSize,
boolean isColor) |
VideoWriter(String filename,
int apiPreference,
int fourcc,
double fps,
Size frameSize) |
VideoWriter(String filename,
int apiPreference,
int fourcc,
double fps,
Size frameSize,
boolean isColor) |
Modifier and Type | Method and Description |
---|---|
static int |
fourcc(byte c1,
byte c2,
byte c3,
byte c4)
\brief Concatenates 4 chars to a fourcc code
|
double |
get(int propId)
\brief Returns the specified VideoWriter property
|
BytePointer |
getBackendName()
\brief Returns used backend API name
|
boolean |
isOpened()
\brief Returns true if video writer has been successfully initialized.
|
boolean |
open(BytePointer filename,
int fourcc,
double fps,
Size frameSize) |
boolean |
open(BytePointer filename,
int fourcc,
double fps,
Size frameSize,
boolean isColor)
\brief Initializes or reinitializes video writer.
|
boolean |
open(BytePointer filename,
int apiPreference,
int fourcc,
double fps,
Size frameSize) |
boolean |
open(BytePointer filename,
int apiPreference,
int fourcc,
double fps,
Size frameSize,
boolean isColor)
\overload
|
boolean |
open(String filename,
int fourcc,
double fps,
Size frameSize) |
boolean |
open(String filename,
int fourcc,
double fps,
Size frameSize,
boolean isColor) |
boolean |
open(String filename,
int apiPreference,
int fourcc,
double fps,
Size frameSize) |
boolean |
open(String filename,
int apiPreference,
int fourcc,
double fps,
Size frameSize,
boolean isColor) |
VideoWriter |
position(long position) |
void |
release()
\brief Closes the video writer.
|
boolean |
set(int propId,
double value)
\brief Sets a property in the VideoWriter.
|
VideoWriter |
shiftLeft(Mat image)
\brief Stream operator to write the next video frame.
|
VideoWriter |
shiftLeft(UMat image)
\overload
|
void |
write(GpuMat image) |
void |
write(Mat image)
\brief Writes the next video frame
|
void |
write(UMat image) |
address, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, hashCode, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetof, parseBytes, physicalBytes, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, toString, totalBytes, totalPhysicalBytes, withDeallocator, zero
public VideoWriter(Pointer p)
Pointer.Pointer(Pointer)
.public VideoWriter(long size)
Pointer.position(long)
.public VideoWriter()
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.
public VideoWriter(@opencv_core.Str BytePointer filename, int fourcc, double fps, @ByVal Size frameSize, @Cast(value="bool") boolean isColor)
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](http://www.fourcc.org/codecs.php) page. FFMPEG backend with MP4 container natively uses
other values as fourcc code: see [ObjectType](http://www.mp4ra.org/codecs.html),
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).
\b 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
) and fourcc=0
OR fps=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.
public VideoWriter(@opencv_core.Str BytePointer filename, int fourcc, double fps, @ByVal Size frameSize)
public VideoWriter(@opencv_core.Str String filename, int fourcc, double fps, @ByVal Size frameSize, @Cast(value="bool") boolean isColor)
public VideoWriter(@opencv_core.Str String filename, int fourcc, double fps, @ByVal Size frameSize)
public VideoWriter(@opencv_core.Str BytePointer filename, int apiPreference, int fourcc, double fps, @ByVal Size frameSize, @Cast(value="bool") boolean isColor)
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.public VideoWriter(@opencv_core.Str BytePointer filename, int apiPreference, int fourcc, double fps, @ByVal Size frameSize)
public VideoWriter(@opencv_core.Str String filename, int apiPreference, int fourcc, double fps, @ByVal Size frameSize, @Cast(value="bool") boolean isColor)
public VideoWriter(@opencv_core.Str String filename, int apiPreference, int fourcc, double fps, @ByVal Size frameSize)
public VideoWriter position(long position)
@Cast(value="bool") public boolean open(@opencv_core.Str BytePointer filename, int fourcc, double fps, @ByVal Size frameSize, @Cast(value="bool") boolean isColor)
The method opens video writer. Parameters are the same as in the constructor VideoWriter::VideoWriter.
true
if video writer has been successfully initialized
The method first calls VideoWriter::release to close the already opened file.
@Cast(value="bool") public boolean open(@opencv_core.Str BytePointer filename, int fourcc, double fps, @ByVal Size frameSize)
@Cast(value="bool") public boolean open(@opencv_core.Str String filename, int fourcc, double fps, @ByVal Size frameSize, @Cast(value="bool") boolean isColor)
@Cast(value="bool") public boolean open(@opencv_core.Str String filename, int fourcc, double fps, @ByVal Size frameSize)
@Cast(value="bool") public boolean open(@opencv_core.Str BytePointer filename, int apiPreference, int fourcc, double fps, @ByVal Size frameSize, @Cast(value="bool") boolean isColor)
@Cast(value="bool") public boolean open(@opencv_core.Str BytePointer filename, int apiPreference, int fourcc, double fps, @ByVal Size frameSize)
@Cast(value="bool") public boolean open(@opencv_core.Str String filename, int apiPreference, int fourcc, double fps, @ByVal Size frameSize, @Cast(value="bool") boolean isColor)
@Cast(value="bool") public boolean open(@opencv_core.Str String filename, int apiPreference, int fourcc, double fps, @ByVal Size frameSize)
@Cast(value="bool") public boolean isOpened()
public void release()
The method is automatically called by subsequent VideoWriter::open and by the VideoWriter destructor.
@ByRef @Name(value="operator <<") public VideoWriter shiftLeft(@Const @ByRef Mat image)
write
@ByRef @Name(value="operator <<") public VideoWriter shiftLeft(@Const @ByRef UMat image)
write
public void write(@ByVal Mat image)
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.
@Cast(value="bool") public boolean set(int propId, double value)
propId
- Property identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY)
or one of \ref videoio_flags_others
value
- Value of the property.true
if the property is supported by the backend used by the VideoWriter instance.public double get(int propId)
propId
- Property identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY)
or one of \ref videoio_flags_others
public static int fourcc(@Cast(value="char") byte c1, @Cast(value="char") byte c2, @Cast(value="char") byte c3, @Cast(value="char") byte c4)
This static method constructs the fourcc code of the codec to be used in the constructor VideoWriter::VideoWriter or VideoWriter::open.
@opencv_core.Str public BytePointer getBackendName()
\note Stream should be opened.
Copyright © 2020. All rights reserved.