Table Of Contents

Previous topic

cudacodec. CUDA-accelerated Video Encoding/Decoding

Next topic

Video Encoding

Video Decoding

cudacodec::VideoReader

Video reader interface.

class cudacodec::VideoReader

Note

  • An example on how to use the videoReader class can be found at opencv_source_code/samples/gpu/video_reader.cpp

cudacodec::VideoReader::nextFrame

Grabs, decodes and returns the next video frame.

C++: bool cudacodec::VideoReader::nextFrame(OutputArray frame)

If no frames has been grabbed (there are no more frames in video file), the methods return false . The method throws Exception if error occurs.

cudacodec::VideoReader::format

Returns information about video file format.

C++: FormatInfo cudacodec::VideoReader::format() const

cudacodec::Codec

Video codecs supported by cudacodec::VideoReader .

C++: enum cudacodec::Codec
MPEG1 = 0
MPEG2
MPEG4
VC1
H264
JPEG
H264_SVC
H264_MVC
Uncompressed_YUV420 = (('I'<<24)|('Y'<<16)|('U'<<8)|('V'))

Y,U,V (4:2:0)

Uncompressed_YV12 = (('Y'<<24)|('V'<<16)|('1'<<8)|('2'))

Y,V,U (4:2:0)

Uncompressed_NV12 = (('N'<<24)|('V'<<16)|('1'<<8)|('2'))

Y,UV (4:2:0)

Uncompressed_YUYV = (('Y'<<24)|('U'<<16)|('Y'<<8)|('V'))

YUYV/YUY2 (4:2:2)

Uncompressed_UYVY = (('U'<<24)|('Y'<<16)|('V'<<8)|('Y'))

UYVY (4:2:2)

cudacodec::ChromaFormat

Chroma formats supported by cudacodec::VideoReader .

C++: enum cudacodec::ChromaFormat
Monochrome = 0
YUV420
YUV422
YUV444

cudacodec::FormatInfo

struct cudacodec::FormatInfo

Struct providing information about video file format.

struct FormatInfo
{
    Codec codec;
    ChromaFormat chromaFormat;
    int width;
    int height;
};

cudacodec::createVideoReader

Creates video reader.

C++: Ptr<VideoReader> cudacodec::createVideoReader(const String& filename)
C++: Ptr<VideoReader> cudacodec::createVideoReader(const Ptr<RawVideoSource>& source)
Parameters:
  • filename – Name of the input video file.
  • source – RAW video source implemented by user.

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

cudacodec::RawVideoSource

class cudacodec::RawVideoSource

Interface for video demultiplexing.

class RawVideoSource
{
public:
    virtual ~RawVideoSource() {}

    virtual bool getNextPacket(unsigned char** data, int* size, bool* endOfFile) = 0;

    virtual FormatInfo format() const = 0;
};

User can implement own demultiplexing by implementing this interface.

cudacodec::RawVideoSource::getNextPacket

Returns next packet with RAW video frame.

C++: bool cudacodec::VideoSource::getNextPacket(unsigned char** data, int* size, bool* endOfFile) = 0
Parameters:
  • data – Pointer to frame data.
  • size – Size in bytes of current frame.
  • endOfStream – Indicates that it is end of stream.

cudacodec::RawVideoSource::format

Returns information about video file format.

C++: virtual FormatInfo cudacodec::RawVideoSource::format() const = 0