@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 fourcc,
double fps,
Size frameSize,
int[] params) |
VideoWriter(BytePointer filename,
int fourcc,
double fps,
Size frameSize,
IntBuffer params) |
VideoWriter(BytePointer filename,
int fourcc,
double fps,
Size frameSize,
IntPointer params)
\overload
The
params parameter allows to specify extra encoder parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... |
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(BytePointer filename,
int apiPreference,
int fourcc,
double fps,
Size frameSize,
int[] params) |
VideoWriter(BytePointer filename,
int apiPreference,
int fourcc,
double fps,
Size frameSize,
IntBuffer params) |
VideoWriter(BytePointer filename,
int apiPreference,
int fourcc,
double fps,
Size frameSize,
IntPointer params)
\overload
|
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 fourcc,
double fps,
Size frameSize,
int[] params) |
VideoWriter(String filename,
int fourcc,
double fps,
Size frameSize,
IntBuffer params) |
VideoWriter(String filename,
int fourcc,
double fps,
Size frameSize,
IntPointer params) |
VideoWriter(String filename,
int apiPreference,
int fourcc,
double fps,
Size frameSize) |
VideoWriter(String filename,
int apiPreference,
int fourcc,
double fps,
Size frameSize,
boolean isColor) |
VideoWriter(String filename,
int apiPreference,
int fourcc,
double fps,
Size frameSize,
int[] params) |
VideoWriter(String filename,
int apiPreference,
int fourcc,
double fps,
Size frameSize,
IntBuffer params) |
VideoWriter(String filename,
int apiPreference,
int fourcc,
double fps,
Size frameSize,
IntPointer params) |
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
|
VideoWriter |
getPointer(long i) |
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 fourcc,
double fps,
Size frameSize,
int[] params) |
boolean |
open(BytePointer filename,
int fourcc,
double fps,
Size frameSize,
IntBuffer params) |
boolean |
open(BytePointer filename,
int fourcc,
double fps,
Size frameSize,
IntPointer params)
\overload
|
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(BytePointer filename,
int apiPreference,
int fourcc,
double fps,
Size frameSize,
int[] params) |
boolean |
open(BytePointer filename,
int apiPreference,
int fourcc,
double fps,
Size frameSize,
IntBuffer params) |
boolean |
open(BytePointer filename,
int apiPreference,
int fourcc,
double fps,
Size frameSize,
IntPointer params)
\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 fourcc,
double fps,
Size frameSize,
int[] params) |
boolean |
open(String filename,
int fourcc,
double fps,
Size frameSize,
IntBuffer params) |
boolean |
open(String filename,
int fourcc,
double fps,
Size frameSize,
IntPointer params) |
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) |
boolean |
open(String filename,
int apiPreference,
int fourcc,
double fps,
Size frameSize,
int[] params) |
boolean |
open(String filename,
int apiPreference,
int fourcc,
double fps,
Size frameSize,
IntBuffer params) |
boolean |
open(String filename,
int apiPreference,
int fourcc,
double fps,
Size frameSize,
IntPointer params) |
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, getDirectBufferAddress, getPointer, getPointer, getPointer, hashCode, interruptDeallocatorThread, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetAddress, offsetof, offsetof, parseBytes, physicalBytes, physicalBytesInaccurate, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, sizeof, toString, totalBytes, totalCount, totalPhysicalBytes, withDeallocator, zero
public VideoWriter(Pointer p)
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
[MSDN](https://docs.microsoft.com/en-us/windows/win32/medfound/video-fourccs) page
or with this [page](https://fourcc.org/codecs.php)
of the fourcc site for a more complete list). FFMPEG backend with MP4 container natively uses
other values as fourcc code: see [ObjectType](http://mp4ra.org/#/codecs),
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.
\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.
- If FFMPEG is used, we allow frames of odd width or height, but in this case we truncate
the rightmost column/the bottom row. Probably, this should be handled more elegantly,
but some internal functions inside FFMPEG swscale require even width/height.
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(@opencv_core.Str BytePointer filename, int fourcc, double fps, @Const @ByRef Size frameSize, @StdVector @Cast(value={"int*","std::vector<int>&"}) IntPointer params)
params
parameter allows to specify extra encoder parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .)
see cv::VideoWriterPropertiespublic VideoWriter(@opencv_core.Str String filename, int fourcc, double fps, @Const @ByRef Size frameSize, @StdVector @Cast(value={"int*","std::vector<int>&"}) IntBuffer params)
public VideoWriter(@opencv_core.Str BytePointer filename, int fourcc, double fps, @Const @ByRef Size frameSize, @StdVector @Cast(value={"int*","std::vector<int>&"}) int[] params)
public VideoWriter(@opencv_core.Str String filename, int fourcc, double fps, @Const @ByRef Size frameSize, @StdVector @Cast(value={"int*","std::vector<int>&"}) IntPointer params)
public VideoWriter(@opencv_core.Str BytePointer filename, int fourcc, double fps, @Const @ByRef Size frameSize, @StdVector @Cast(value={"int*","std::vector<int>&"}) IntBuffer params)
public VideoWriter(@opencv_core.Str String filename, int fourcc, double fps, @Const @ByRef Size frameSize, @StdVector @Cast(value={"int*","std::vector<int>&"}) int[] params)
public VideoWriter(@opencv_core.Str BytePointer filename, int apiPreference, int fourcc, double fps, @Const @ByRef Size frameSize, @StdVector @Cast(value={"int*","std::vector<int>&"}) IntPointer params)
public VideoWriter(@opencv_core.Str String filename, int apiPreference, int fourcc, double fps, @Const @ByRef Size frameSize, @StdVector @Cast(value={"int*","std::vector<int>&"}) IntBuffer params)
public VideoWriter(@opencv_core.Str BytePointer filename, int apiPreference, int fourcc, double fps, @Const @ByRef Size frameSize, @StdVector @Cast(value={"int*","std::vector<int>&"}) int[] params)
public VideoWriter(@opencv_core.Str String filename, int apiPreference, int fourcc, double fps, @Const @ByRef Size frameSize, @StdVector @Cast(value={"int*","std::vector<int>&"}) IntPointer params)
public VideoWriter(@opencv_core.Str BytePointer filename, int apiPreference, int fourcc, double fps, @Const @ByRef Size frameSize, @StdVector @Cast(value={"int*","std::vector<int>&"}) IntBuffer params)
public VideoWriter(@opencv_core.Str String filename, int apiPreference, int fourcc, double fps, @Const @ByRef Size frameSize, @StdVector @Cast(value={"int*","std::vector<int>&"}) int[] params)
public VideoWriter position(long position)
public VideoWriter getPointer(long i)
getPointer
in class Pointer
@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 open(@opencv_core.Str BytePointer filename, int fourcc, double fps, @Const @ByRef Size frameSize, @StdVector @Cast(value={"int*","std::vector<int>&"}) IntPointer params)
@Cast(value="bool") public boolean open(@opencv_core.Str String filename, int fourcc, double fps, @Const @ByRef Size frameSize, @StdVector @Cast(value={"int*","std::vector<int>&"}) IntBuffer params)
@Cast(value="bool") public boolean open(@opencv_core.Str BytePointer filename, int fourcc, double fps, @Const @ByRef Size frameSize, @StdVector @Cast(value={"int*","std::vector<int>&"}) int[] params)
@Cast(value="bool") public boolean open(@opencv_core.Str String filename, int fourcc, double fps, @Const @ByRef Size frameSize, @StdVector @Cast(value={"int*","std::vector<int>&"}) IntPointer params)
@Cast(value="bool") public boolean open(@opencv_core.Str BytePointer filename, int fourcc, double fps, @Const @ByRef Size frameSize, @StdVector @Cast(value={"int*","std::vector<int>&"}) IntBuffer params)
@Cast(value="bool") public boolean open(@opencv_core.Str String filename, int fourcc, double fps, @Const @ByRef Size frameSize, @StdVector @Cast(value={"int*","std::vector<int>&"}) int[] params)
@Cast(value="bool") public boolean open(@opencv_core.Str BytePointer filename, int apiPreference, int fourcc, double fps, @Const @ByRef Size frameSize, @StdVector @Cast(value={"int*","std::vector<int>&"}) IntPointer params)
@Cast(value="bool") public boolean open(@opencv_core.Str String filename, int apiPreference, int fourcc, double fps, @Const @ByRef Size frameSize, @StdVector @Cast(value={"int*","std::vector<int>&"}) IntBuffer params)
@Cast(value="bool") public boolean open(@opencv_core.Str BytePointer filename, int apiPreference, int fourcc, double fps, @Const @ByRef Size frameSize, @StdVector @Cast(value={"int*","std::vector<int>&"}) int[] params)
@Cast(value="bool") public boolean open(@opencv_core.Str String filename, int apiPreference, int fourcc, double fps, @Const @ByRef Size frameSize, @StdVector @Cast(value={"int*","std::vector<int>&"}) IntPointer params)
@Cast(value="bool") public boolean open(@opencv_core.Str BytePointer filename, int apiPreference, int fourcc, double fps, @Const @ByRef Size frameSize, @StdVector @Cast(value={"int*","std::vector<int>&"}) IntBuffer params)
@Cast(value="bool") public boolean open(@opencv_core.Str String filename, int apiPreference, int fourcc, double fps, @Const @ByRef Size frameSize, @StdVector @Cast(value={"int*","std::vector<int>&"}) int[] params)
@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 © 2024. All rights reserved.