### Navigation

- index
- next |
- previous |
- OpenCV 3.0.0.0-dev documentation »
- OpenCV API Reference »
- gpucodec. GPU-accelerated Video Encoding/Decoding »

# Video Decoding

## gpucodec::VideoReader

Video reader interface.

class `gpucodec::``VideoReader`

Note

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

## gpucodec::VideoReader::nextFrame

Grabs, decodes and returns the next video frame.

C++:`` bool `gpucodec::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.

## gpucodec::VideoReader::format

Returns information about video file format.

C++:`` FormatInfo `gpucodec::VideoReader::``format`()`const`

## gpucodec::Codec

Video codecs supported by `gpucodec::VideoReader` .

C++:`` enum `gpucodec::``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)

## gpucodec::ChromaFormat

Chroma formats supported by `gpucodec::VideoReader` .

C++:`` enum `gpucodec::``ChromaFormat`
  `Monochrome` = 0
  `YUV420`
  `YUV422`
  `YUV444`

## gpucodec::FormatInfo

struct `gpucodec::``FormatInfo`

Struct providing information about video file format.

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

## gpucodec::createVideoReader

Creates video reader.

C++:`` Ptr<VideoReader> `gpucodec::``createVideoReader`(const String& filename)

C++:`` Ptr<VideoReader> `gpucodec::``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 `gpucodec::RawVideoSource` .

## gpucodec::RawVideoSource

class `gpucodec::``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.

## gpucodec::RawVideoSource::getNextPacket

Returns next packet with RAW video frame.

C++:`` bool `gpucodec::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.

## gpucodec::RawVideoSource::format

Returns information about video file format.

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

## Help and Feedback

You did not find what you were looking for?

- Ask a question on the Q&A forum.
- If you think something is missing or wrong in the documentation, please file a bug report.

### Navigation

- index
- next |
- previous |
- OpenCV 3.0.0.0-dev documentation »
- OpenCV API Reference »
- gpucodec. GPU-accelerated Video Encoding/Decoding »