Video Encoding/Decoding

Overview

// enums

enum cv::cudacodec::ChromaFormat;
enum cv::cudacodec::Codec;
enum cv::cudacodec::SurfaceFormat;

// structs

struct cv::cudacodec::EncoderParams;
struct cv::cudacodec::FormatInfo;

// classes

class cv::cudacodec::EncoderCallBack;
class cv::cudacodec::RawVideoSource;
class cv::cudacodec::VideoReader;
class cv::cudacodec::VideoWriter;

// global functions

Ptr<VideoReader>
cv::cudacodec::createVideoReader(const String& filename);

Ptr<VideoReader>
cv::cudacodec::createVideoReader(const Ptr<RawVideoSource>& source);

Ptr<VideoWriter>
cv::cudacodec::createVideoWriter(
    const String& fileName,
    Size frameSize,
    double fps,
    SurfaceFormat format = SF_BGR
    );

Ptr<VideoWriter>
cv::cudacodec::createVideoWriter(
    const String& fileName,
    Size frameSize,
    double fps,
    const EncoderParams& params,
    SurfaceFormat format = SF_BGR
    );

Ptr<VideoWriter>
cv::cudacodec::createVideoWriter(
    const Ptr<EncoderCallBack>& encoderCallback,
    Size frameSize,
    double fps,
    SurfaceFormat format = SF_BGR
    );

Ptr<VideoWriter>
cv::cudacodec::createVideoWriter(
    const Ptr<EncoderCallBack>& encoderCallback,
    Size frameSize,
    double fps,
    const EncoderParams& params,
    SurfaceFormat format = SF_BGR
    );

Detailed Documentation

Global Functions

Ptr<VideoReader>
cv::cudacodec::createVideoReader(const String& filename)

Creates video reader.

FFMPEG is used to read videos. User can implement own demultiplexing with cudacodec::RawVideoSource

Parameters:

filename Name of the input video file.
Ptr<VideoReader>
cv::cudacodec::createVideoReader(const Ptr<RawVideoSource>& source)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:

source RAW video source implemented by user.
Ptr<VideoWriter>
cv::cudacodec::createVideoWriter(
    const String& fileName,
    Size frameSize,
    double fps,
    SurfaceFormat format = SF_BGR
    )

Creates video writer.

The constructors initialize video writer. FFMPEG is used to write videos. User can implement own multiplexing with cudacodec::EncoderCallBack.

Parameters:

fileName Name of the output video file. Only AVI file format is supported.
frameSize Size of the input video frames.
fps Framerate of the created video stream.
format Surface format of input frames ( SF_UYVY , SF_YUY2 , SF_YV12 , SF_NV12 , SF_IYUV , SF_BGR or SF_GRAY). BGR or gray frames will be converted to YV12 format before encoding, frames with other formats will be used as is.
Ptr<VideoWriter>
cv::cudacodec::createVideoWriter(
    const String& fileName,
    Size frameSize,
    double fps,
    const EncoderParams& params,
    SurfaceFormat format = SF_BGR
    )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:

fileName Name of the output video file. Only AVI file format is supported.
frameSize Size of the input video frames.
fps Framerate of the created video stream.
params Encoder parameters. See cudacodec::EncoderParams.
format Surface format of input frames ( SF_UYVY , SF_YUY2 , SF_YV12 , SF_NV12 , SF_IYUV , SF_BGR or SF_GRAY). BGR or gray frames will be converted to YV12 format before encoding, frames with other formats will be used as is.
Ptr<VideoWriter>
cv::cudacodec::createVideoWriter(
    const Ptr<EncoderCallBack>& encoderCallback,
    Size frameSize,
    double fps,
    SurfaceFormat format = SF_BGR
    )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:

encoderCallback Callbacks for video encoder. See cudacodec::EncoderCallBack. Use it if you want to work with raw video stream.
frameSize Size of the input video frames.
fps Framerate of the created video stream.
format Surface format of input frames ( SF_UYVY , SF_YUY2 , SF_YV12 , SF_NV12 , SF_IYUV , SF_BGR or SF_GRAY). BGR or gray frames will be converted to YV12 format before encoding, frames with other formats will be used as is.
Ptr<VideoWriter>
cv::cudacodec::createVideoWriter(
    const Ptr<EncoderCallBack>& encoderCallback,
    Size frameSize,
    double fps,
    const EncoderParams& params,
    SurfaceFormat format = SF_BGR
    )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:

encoderCallback Callbacks for video encoder. See cudacodec::EncoderCallBack. Use it if you want to work with raw video stream.
frameSize Size of the input video frames.
fps Framerate of the created video stream.
params Encoder parameters. See cudacodec::EncoderParams.
format Surface format of input frames ( SF_UYVY , SF_YUY2 , SF_YV12 , SF_NV12 , SF_IYUV , SF_BGR or SF_GRAY). BGR or gray frames will be converted to YV12 format before encoding, frames with other formats will be used as is.