View Source Evision.VideoWriter (Evision v0.1.38)

Summary

Types

t()

Type that represents an VideoWriter struct.

Functions

Concatenates 4 chars to a fourcc code

Returns the specified VideoWriter property

Returns used backend API name

Returns true if video writer has been successfully initialized.

Initializes or reinitializes video writer.

Closes the video writer.

Sets a property in the VideoWriter.

Default constructors

Writes the next video frame

Types

@type t() :: %Evision.VideoWriter{ref: reference()}

Type that represents an VideoWriter struct.

  • ref. reference()

    The underlying erlang resource variable.

Functions

@spec fourcc(char(), char(), char(), char()) :: integer() | {:error, String.t()}

Concatenates 4 chars to a fourcc code

Positional Arguments
  • c1: char
  • c2: char
  • c3: char
  • c4: char
Return
  • retval: int

@return a fourcc code This static method constructs the fourcc code of the codec to be used in the constructor VideoWriter::VideoWriter or VideoWriter::open.

Python prototype (for reference only):

fourcc(c1, c2, c3, c4) -> retval
@spec get(t(), integer()) :: number() | {:error, String.t()}

Returns the specified VideoWriter property

Positional Arguments
  • self: Evision.VideoWriter.t()

  • propId: int.

    Property identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY) or one of @ref videoio_flags_others

Return
  • retval: double

@return 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.

Python prototype (for reference only):

get(propId) -> retval
@spec getBackendName(t()) :: binary() | {:error, String.t()}

Returns used backend API name

Positional Arguments
  • self: Evision.VideoWriter.t()
Return

Note: Stream should be opened.

Python prototype (for reference only):

getBackendName() -> retval
@spec isOpened(t()) :: boolean() | {:error, String.t()}

Returns true if video writer has been successfully initialized.

Positional Arguments
  • self: Evision.VideoWriter.t()
Return
  • retval: bool

Python prototype (for reference only):

isOpened() -> retval
Link to this function

open(self, filename, fourcc, fps, frameSize)

View Source
@spec open(t(), binary(), integer(), number(), {number(), number()}) ::
  boolean() | {:error, String.t()}

Initializes or reinitializes video writer.

Positional Arguments
  • self: Evision.VideoWriter.t()
  • filename: String
  • fourcc: int
  • fps: double
  • frameSize: Size
Keyword Arguments
  • isColor: bool.
Return
  • retval: bool

The method opens video writer. Parameters are the same as in the constructor VideoWriter::VideoWriter. @return true if video writer has been successfully initialized The method first calls VideoWriter::release to close the already opened file.

Python prototype (for reference only):

open(filename, fourcc, fps, frameSize[, isColor]) -> retval
Link to this function

open(self, filename, fourcc, fps, frameSize, opts)

View Source
@spec open(
  t(),
  binary(),
  integer(),
  number(),
  {number(), number()},
  [{atom(), term()}, ...] | nil
) ::
  boolean() | {:error, String.t()}
@spec open(t(), binary(), integer(), number(), {number(), number()}, [integer()]) ::
  boolean() | {:error, String.t()}
@spec open(t(), binary(), integer(), integer(), number(), {number(), number()}) ::
  boolean() | {:error, String.t()}

Variant 1:

open

Positional Arguments
  • self: Evision.VideoWriter.t()
  • filename: String
  • fourcc: int
  • fps: double
  • frameSize: Size
  • params: [int]
Return
  • retval: bool

Has overloading in C++

Python prototype (for reference only):

open(filename, fourcc, fps, frameSize, params) -> retval

Variant 2:

open

Positional Arguments
  • self: Evision.VideoWriter.t()
  • filename: String
  • apiPreference: int
  • fourcc: int
  • fps: double
  • frameSize: Size
Keyword Arguments
  • isColor: bool.
Return
  • retval: bool

Has overloading in C++

Python prototype (for reference only):

open(filename, apiPreference, fourcc, fps, frameSize[, isColor]) -> retval

Variant 3:

Initializes or reinitializes video writer.

Positional Arguments
  • self: Evision.VideoWriter.t()
  • filename: String
  • fourcc: int
  • fps: double
  • frameSize: Size
Keyword Arguments
  • isColor: bool.
Return
  • retval: bool

The method opens video writer. Parameters are the same as in the constructor VideoWriter::VideoWriter. @return true if video writer has been successfully initialized The method first calls VideoWriter::release to close the already opened file.

Python prototype (for reference only):

open(filename, fourcc, fps, frameSize[, isColor]) -> retval
Link to this function

open(self, filename, apiPreference, fourcc, fps, frameSize, opts)

View Source
@spec open(
  t(),
  binary(),
  integer(),
  integer(),
  number(),
  {number(), number()},
  [{atom(), term()}, ...] | nil
) :: boolean() | {:error, String.t()}
@spec open(t(), binary(), integer(), integer(), number(), {number(), number()}, [
  integer()
]) ::
  boolean() | {:error, String.t()}

Variant 1:

open

Positional Arguments
  • self: Evision.VideoWriter.t()
  • filename: String
  • apiPreference: int
  • fourcc: int
  • fps: double
  • frameSize: Size
  • params: [int]
Return
  • retval: bool

Has overloading in C++

Python prototype (for reference only):

open(filename, apiPreference, fourcc, fps, frameSize, params) -> retval

Variant 2:

open

Positional Arguments
  • self: Evision.VideoWriter.t()
  • filename: String
  • apiPreference: int
  • fourcc: int
  • fps: double
  • frameSize: Size
Keyword Arguments
  • isColor: bool.
Return
  • retval: bool

Has overloading in C++

Python prototype (for reference only):

open(filename, apiPreference, fourcc, fps, frameSize[, isColor]) -> retval
@spec release(t()) :: t() | {:error, String.t()}

Closes the video writer.

Positional Arguments
  • self: Evision.VideoWriter.t()

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

Python prototype (for reference only):

release() -> None
Link to this function

set(self, propId, value)

View Source
@spec set(t(), integer(), number()) :: boolean() | {:error, String.t()}

Sets a property in the VideoWriter.

Positional Arguments
  • self: Evision.VideoWriter.t()

  • propId: int.

    Property identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY) or one of @ref videoio_flags_others

  • value: double.

    Value of the property.

Return
  • retval: bool

@return true if the property is supported by the backend used by the VideoWriter instance.

Python prototype (for reference only):

set(propId, value) -> retval
@spec videoWriter() :: t() | {:error, String.t()}

Default constructors

Return
  • self: Evision.VideoWriter.t()

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.

Python prototype (for reference only):

VideoWriter() -> <VideoWriter object>
Link to this function

videoWriter(filename, fourcc, fps, frameSize)

View Source
@spec videoWriter(binary(), integer(), number(), {number(), number()}) ::
  t() | {:error, String.t()}

VideoWriter

Positional Arguments
  • filename: String.

    Name of the output video file.

  • fourcc: int.

    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 page or with this page of the fourcc site for a more complete list). FFMPEG backend with MP4 container natively uses other values as fourcc code: see ObjectType, so you may receive a warning message from OpenCV about fourcc code conversion.

  • fps: double.

    Framerate of the created video stream.

  • frameSize: Size.

    Size of the video frames.

Keyword Arguments
  • isColor: bool.

    If it is not zero, the encoder will expect and encode color frames, otherwise it will work with grayscale frames.

Return
  • self: Evision.VideoWriter.t()

Has overloading in C++

@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.

Python prototype (for reference only):

VideoWriter(filename, fourcc, fps, frameSize[, isColor]) -> <VideoWriter object>
Link to this function

videoWriter(filename, fourcc, fps, frameSize, opts)

View Source
@spec videoWriter(
  binary(),
  integer(),
  number(),
  {number(), number()},
  [{atom(), term()}, ...] | nil
) ::
  t() | {:error, String.t()}
@spec videoWriter(binary(), integer(), number(), {number(), number()}, [integer()]) ::
  t() | {:error, String.t()}
@spec videoWriter(binary(), integer(), integer(), number(), {number(), number()}) ::
  t() | {:error, String.t()}

Variant 1:

VideoWriter

Positional Arguments
  • filename: String
  • fourcc: int
  • fps: double
  • frameSize: Size
  • params: [int]
Return
  • self: Evision.VideoWriter.t()

Has overloading in C++

The params parameter allows to specify extra encoder parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) see cv::VideoWriterProperties

Python prototype (for reference only):

VideoWriter(filename, fourcc, fps, frameSize, params) -> <VideoWriter object>

Variant 2:

VideoWriter

Positional Arguments
  • filename: String
  • apiPreference: int
  • fourcc: int
  • fps: double
  • frameSize: Size
Keyword Arguments
  • isColor: bool.
Return
  • self: Evision.VideoWriter.t()

Has overloading in C++

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.

Python prototype (for reference only):

VideoWriter(filename, apiPreference, fourcc, fps, frameSize[, isColor]) -> <VideoWriter object>

Variant 3:

VideoWriter

Positional Arguments
  • filename: String.

    Name of the output video file.

  • fourcc: int.

    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 page or with this page of the fourcc site for a more complete list). FFMPEG backend with MP4 container natively uses other values as fourcc code: see ObjectType, so you may receive a warning message from OpenCV about fourcc code conversion.

  • fps: double.

    Framerate of the created video stream.

  • frameSize: Size.

    Size of the video frames.

Keyword Arguments
  • isColor: bool.

    If it is not zero, the encoder will expect and encode color frames, otherwise it will work with grayscale frames.

Return
  • self: Evision.VideoWriter.t()

Has overloading in C++

@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.

Python prototype (for reference only):

VideoWriter(filename, fourcc, fps, frameSize[, isColor]) -> <VideoWriter object>
Link to this function

videoWriter(filename, apiPreference, fourcc, fps, frameSize, opts)

View Source
@spec videoWriter(
  binary(),
  integer(),
  integer(),
  number(),
  {number(), number()},
  [{atom(), term()}, ...] | nil
) :: t() | {:error, String.t()}
@spec videoWriter(binary(), integer(), integer(), number(), {number(), number()}, [
  integer()
]) ::
  t() | {:error, String.t()}

Variant 1:

VideoWriter

Positional Arguments
  • filename: String
  • apiPreference: int
  • fourcc: int
  • fps: double
  • frameSize: Size
  • params: [int]
Return
  • self: Evision.VideoWriter.t()

Has overloading in C++

Python prototype (for reference only):

VideoWriter(filename, apiPreference, fourcc, fps, frameSize, params) -> <VideoWriter object>

Variant 2:

VideoWriter

Positional Arguments
  • filename: String
  • apiPreference: int
  • fourcc: int
  • fps: double
  • frameSize: Size
Keyword Arguments
  • isColor: bool.
Return
  • self: Evision.VideoWriter.t()

Has overloading in C++

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.

Python prototype (for reference only):

VideoWriter(filename, apiPreference, fourcc, fps, frameSize[, isColor]) -> <VideoWriter object>
@spec write(t(), Evision.Mat.maybe_mat_in()) :: t() | {:error, String.t()}

Writes the next video frame

Positional Arguments
  • self: Evision.VideoWriter.t()

  • image: Evision.Mat.t().

    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.

Python prototype (for reference only):

write(image) -> None