org.opencv.videoio

## Class VideoWriter

- java.lang.Object
- - org.opencv.videoio.VideoWriter

-     public class VideoWriter
      extends Object

  Video writer class. The class provides C++ API for writing video files or image sequences.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected long` | `nativeObj`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `` | `VideoWriter()` Default constructors The constructors/functions initialize video writers.
    `protected` | `VideoWriter(long addr)`
    `` | `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)` The `apiPreference` parameter allows to specify API backends to use.
    `` | `VideoWriter(String filename, int apiPreference, int fourcc, double fps, Size frameSize, boolean isColor)` The `apiPreference` parameter allows to specify API backends to use.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static VideoWriter` | `__fromPtr__(long addr)`
    `protected void` | `finalize()`
    `static int` | `fourcc(char c1, char c2, char c3, char c4)` Concatenates 4 chars to a fourcc code
    `double` | `get(int propId)` Returns the specified VideoWriter property
    `String` | `getBackendName()` Returns used backend API name Note: Stream should be opened.
    `long` | `getNativeObjAddr()`
    `boolean` | `isOpened()` Returns true if video writer has been successfully initialized.
    `boolean` | `open(String filename, int fourcc, double fps, Size frameSize)` Initializes or reinitializes video writer.
    `boolean` | `open(String filename, int fourcc, double fps, Size frameSize, boolean isColor)` Initializes or reinitializes video writer.
    `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)`
    `void` | `release()` Closes the video writer.
    `boolean` | `set(int propId, double value)` Sets a property in the VideoWriter.
    `void` | `write(Mat image)` Writes the next video frame

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### nativeObj

          protected final long nativeObj

  - ### Constructor Detail

    - #### VideoWriter

          protected VideoWriter(long addr)

    - #### VideoWriter

          public VideoWriter(String filename,
                             int apiPreference,
                             int fourcc,
                             double fps,
                             Size frameSize,
                             boolean isColor)

      The `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.
      Parameters:
        `filename` - automatically generated
        `apiPreference` - automatically generated
        `fourcc` - automatically generated
        `fps` - automatically generated
        `frameSize` - automatically generated
        `isColor` - automatically generated

    - #### VideoWriter

          public VideoWriter(String filename,
                             int apiPreference,
                             int fourcc,
                             double fps,
                             Size frameSize)

      The `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.
      Parameters:
        `filename` - automatically generated
        `apiPreference` - automatically generated
        `fourcc` - automatically generated
        `fps` - automatically generated
        `frameSize` - automatically generated

    - #### VideoWriter

          public VideoWriter(String filename,
                             int fourcc,
                             double fps,
                             Size frameSize,
                             boolean isColor)

      Parameters:
        `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). 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.

    - #### VideoWriter

          public VideoWriter(String filename,
                             int fourcc,
                             double fps,
                             Size frameSize)

      Parameters:
        `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. 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`) 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.

    - #### VideoWriter

          public VideoWriter()

      Default constructors The constructors/functions initialize video writers.
      - On Linux FFMPEG is used to write videos;
      - On Windows FFMPEG or VFW is used;
      - On MacOSX QTKit is used.

  - ### Method Detail

    - #### getNativeObjAddr

          public long getNativeObjAddr()

    - #### __fromPtr__

          public static VideoWriter __fromPtr__(long addr)

    - #### getBackendName

          public String getBackendName()

      Returns used backend API name Note: Stream should be opened.
      Returns:
        automatically generated

    - #### isOpened

          public boolean isOpened()

      Returns true if video writer has been successfully initialized.
      Returns:
        automatically generated

    - #### open

          public boolean open(String filename,
                              int apiPreference,
                              int fourcc,
                              double fps,
                              Size frameSize,
                              boolean isColor)

    - #### open

          public boolean open(String filename,
                              int apiPreference,
                              int fourcc,
                              double fps,
                              Size frameSize)

    - #### open

          public boolean open(String filename,
                              int fourcc,
                              double fps,
                              Size frameSize,
                              boolean isColor)

      Initializes or reinitializes video writer. The method opens video writer. Parameters are the same as in the constructor VideoWriter::VideoWriter.
      Parameters:
        `filename` - automatically generated
        `fourcc` - automatically generated
        `fps` - automatically generated
        `frameSize` - automatically generated
        `isColor` - automatically generated
      Returns:
        `true` if video writer has been successfully initialized The method first calls VideoWriter::release to close the already opened file.

    - #### open

          public boolean open(String filename,
                              int fourcc,
                              double fps,
                              Size frameSize)

      Initializes or reinitializes video writer. The method opens video writer. Parameters are the same as in the constructor VideoWriter::VideoWriter.
      Parameters:
        `filename` - automatically generated
        `fourcc` - automatically generated
        `fps` - automatically generated
        `frameSize` - automatically generated
      Returns:
        `true` if video writer has been successfully initialized The method first calls VideoWriter::release to close the already opened file.

    - #### set

          public boolean set(int propId,
                             double value)

      Sets a property in the VideoWriter.
      Parameters:
        `propId` - Property identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY) or one of REF: videoio_flags_others
        `value` - Value of the property.
      Returns:
        `true` if the property is supported by the backend used by the VideoWriter instance.

    - #### get

          public double get(int propId)

      Returns the specified VideoWriter property
      Parameters:
        `propId` - Property identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY) or one of REF: videoio_flags_others
      Returns:
        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.

    - #### fourcc

          public static int fourcc(char c1,
                                   char c2,
                                   char c3,
                                   char c4)

      Concatenates 4 chars to a fourcc code
      Parameters:
        `c1` - automatically generated
        `c2` - automatically generated
        `c3` - automatically generated
        `c4` - automatically generated
      Returns:
        a fourcc code This static method constructs the fourcc code of the codec to be used in the constructor VideoWriter::VideoWriter or VideoWriter::open.

    - #### release

          public void release()

      Closes the video writer. The method is automatically called by subsequent VideoWriter::open and by the VideoWriter destructor.

    - #### write

          public void write(Mat image)

      Writes the next video frame
      Parameters:
        `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.

    - #### finalize

          protected void finalize()
                           throws Throwable

      Overrides:
        `finalize` in class `Object`
      Throws:
        `Throwable`

Generated on Wed Oct 9 2019 16:55:37 UTC / OpenCV 3.4.8