2013-06-04 17:32:35 +08:00
Video Decoding
==============
.. highlight :: cpp
2013-08-20 19:05:49 +08:00
cudacodec::VideoReader
----------------------
2013-06-11 17:05:02 +08:00
Video reader interface.
2013-06-04 17:32:35 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:class :: cudacodec::VideoReader
2013-06-04 17:32:35 +08:00
2013-08-13 16:56:39 +08:00
.. note ::
2013-08-06 17:56:49 +08:00
2013-08-13 16:56:39 +08:00
* An example on how to use the videoReader class can be found at opencv_source_code/samples/gpu/video_reader.cpp
2013-06-04 17:32:35 +08:00
2013-08-20 19:05:49 +08:00
cudacodec::VideoReader::nextFrame
---------------------------------
2013-06-11 17:05:02 +08:00
Grabs, decodes and returns the next video frame.
2013-08-20 19:05:49 +08:00
.. ocv:function :: bool cudacodec::VideoReader::nextFrame(OutputArray frame)
2013-06-11 17:05:02 +08:00
If no frames has been grabbed (there are no more frames in video file), the methods return `` false `` . The method throws :ocv:class: `Exception` if error occurs.
2013-08-20 19:05:49 +08:00
cudacodec::VideoReader::format
------------------------------
2013-06-11 17:05:02 +08:00
Returns information about video file format.
2013-08-20 19:05:49 +08:00
.. ocv:function :: FormatInfo cudacodec::VideoReader::format() const
2013-06-11 17:05:02 +08:00
2013-06-04 17:32:35 +08:00
2013-08-20 19:05:49 +08:00
cudacodec::Codec
----------------
Video codecs supported by :ocv:class: `cudacodec::VideoReader` .
2013-06-11 17:05:02 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:enum :: cudacodec::Codec
2013-06-04 17:32:35 +08:00
.. ocv:emember :: MPEG1 = 0
.. ocv:emember :: MPEG2
.. ocv:emember :: MPEG4
.. ocv:emember :: VC1
.. ocv:emember :: H264
.. ocv:emember :: JPEG
.. ocv:emember :: H264_SVC
.. ocv:emember :: H264_MVC
.. ocv:emember :: Uncompressed_YUV420 = (('I'<<24)|('Y'<<16)|('U'<<8)|('V'))
Y,U,V (4:2:0)
.. ocv:emember :: Uncompressed_YV12 = (('Y'<<24)|('V'<<16)|('1'<<8)|('2'))
Y,V,U (4:2:0)
.. ocv:emember :: Uncompressed_NV12 = (('N'<<24)|('V'<<16)|('1'<<8)|('2'))
Y,UV (4:2:0)
.. ocv:emember :: Uncompressed_YUYV = (('Y'<<24)|('U'<<16)|('Y'<<8)|('V'))
YUYV/YUY2 (4:2:2)
.. ocv:emember :: Uncompressed_UYVY = (('U'<<24)|('Y'<<16)|('V'<<8)|('Y'))
UYVY (4:2:2)
2013-08-20 19:05:49 +08:00
cudacodec::ChromaFormat
-----------------------
Chroma formats supported by :ocv:class: `cudacodec::VideoReader` .
2013-06-04 17:32:35 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:enum :: cudacodec::ChromaFormat
2013-06-04 17:32:35 +08:00
.. ocv:emember :: Monochrome = 0
.. ocv:emember :: YUV420
.. ocv:emember :: YUV422
.. ocv:emember :: YUV444
2013-06-11 17:05:02 +08:00
2013-08-20 19:05:49 +08:00
cudacodec::FormatInfo
---------------------
.. ocv:struct :: cudacodec::FormatInfo
2013-06-04 17:32:35 +08:00
Struct providing information about video file format. ::
struct FormatInfo
{
Codec codec;
ChromaFormat chromaFormat;
int width;
int height;
};
2013-08-20 19:05:49 +08:00
cudacodec::createVideoReader
----------------------------
2013-06-11 17:05:02 +08:00
Creates video reader.
2013-06-04 17:32:35 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: Ptr<VideoReader> cudacodec::createVideoReader(const String& filename)
.. ocv:function :: Ptr<VideoReader> cudacodec::createVideoReader(const Ptr<RawVideoSource>& source)
2013-06-04 17:32:35 +08:00
2013-06-11 17:05:02 +08:00
:param filename: Name of the input video file.
2013-06-04 17:32:35 +08:00
2013-06-11 17:05:02 +08:00
:param source: RAW video source implemented by user.
2013-06-04 17:32:35 +08:00
2013-08-20 19:05:49 +08:00
FFMPEG is used to read videos. User can implement own demultiplexing with :ocv:class: `cudacodec::RawVideoSource` .
2013-06-04 17:32:35 +08:00
2013-08-20 19:05:49 +08:00
cudacodec::RawVideoSource
-------------------------
.. ocv:class :: cudacodec::RawVideoSource
2013-06-04 17:32:35 +08:00
Interface for video demultiplexing. ::
2013-06-11 17:05:02 +08:00
class RawVideoSource
2013-06-04 17:32:35 +08:00
{
public:
2013-06-11 17:05:02 +08:00
virtual ~RawVideoSource() {}
2013-06-04 17:32:35 +08:00
2013-06-11 17:05:02 +08:00
virtual bool getNextPacket(unsigned char** data, int* size, bool* endOfFile) = 0;
2013-06-04 17:32:35 +08:00
2013-06-11 17:05:02 +08:00
virtual FormatInfo format() const = 0;
2013-06-04 17:32:35 +08:00
};
User can implement own demultiplexing by implementing this interface.
2013-08-20 19:05:49 +08:00
cudacodec::RawVideoSource::getNextPacket
----------------------------------------
2013-06-11 17:05:02 +08:00
Returns next packet with RAW video frame.
2013-06-04 17:32:35 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: bool cudacodec::VideoSource::getNextPacket(unsigned char** data, int* size, bool* endOfFile) = 0
2013-06-04 17:32:35 +08:00
2013-06-11 17:05:02 +08:00
:param data: Pointer to frame data.
2013-06-04 17:32:35 +08:00
2013-06-11 17:05:02 +08:00
:param size: Size in bytes of current frame.
2013-06-04 17:32:35 +08:00
2013-06-11 17:05:02 +08:00
:param endOfStream: Indicates that it is end of stream.
2013-06-04 17:32:35 +08:00
2013-08-20 19:05:49 +08:00
cudacodec::RawVideoSource::format
---------------------------------
2013-06-11 17:05:02 +08:00
Returns information about video file format.
2013-06-04 17:32:35 +08:00
2013-08-20 19:05:49 +08:00
.. ocv:function :: virtual FormatInfo cudacodec::RawVideoSource::format() const = 0