QVideoFrame Class

The QVideoFrame class represents a frame of video data. More...

Header: #include <QVideoFrame>
qmake: QT += multimedia

Public Types

enum FieldType { ProgressiveFrame, TopField, BottomField, InterlacedFrame }
enum PixelFormat { Format_Invalid, Format_ARGB32, Format_ARGB32_Premultiplied, Format_RGB32, Format_RGB24, …, Format_User }

Detailed Description

A QVideoFrame encapsulates the pixel data of a video frame, and information about the frame.

Video frames can come from several places - decoded media, a camera, or generated programmatically. The way pixels are described in these frames can vary greatly, and some pixel formats offer greater compression opportunities at the expense of ease of use.

The pixel contents of a video frame can be mapped to memory using the map() function. While mapped, the video data can accessed using the bits() function, which returns a pointer to a buffer. The total size of this buffer is given by the mappedBytes() function, and the size of each line is given by bytesPerLine(). The return value of the handle() function may also be used to access frame data using the internal buffer's native APIs (for example - an OpenGL texture handle).

A video frame can also have timestamp information associated with it. These timestamps can be used by an implementation of QAbstractVideoSurface to determine when to start and stop displaying the frame, but not all surfaces might respect this setting.

The video pixel data in a QVideoFrame is encapsulated in a QAbstractVideoBuffer. A QVideoFrame may be constructed from any buffer type by subclassing the QAbstractVideoBuffer class.

Note: Since video frames can be expensive to copy, QVideoFrame is explicitly shared, so any change made to a video frame will also apply to any copies.

Member Type Documentation

enum QVideoFrame::FieldType

Specifies the field an interlaced video frame belongs to.

ConstantValueDescription
QVideoFrame::ProgressiveFrame0The frame is not interlaced.
QVideoFrame::TopField1The frame contains a top field.
QVideoFrame::BottomField2The frame contains a bottom field.
QVideoFrame::InterlacedFrame3The frame contains a merged top and bottom field.

enum QVideoFrame::PixelFormat

Enumerates video data types.

ConstantValueDescription
QVideoFrame::Format_Invalid0The frame is invalid.
QVideoFrame::Format_ARGB321The frame is stored using a 32-bit ARGB format (0xAARRGGBB). This is equivalent to QImage::Format_ARGB32.
QVideoFrame::Format_ARGB32_Premultiplied2The frame stored using a premultiplied 32-bit ARGB format (0xAARRGGBB). This is equivalent to QImage::Format_ARGB32_Premultiplied.
QVideoFrame::Format_RGB323The frame stored using a 32-bit RGB format (0xffRRGGBB). This is equivalent to QImage::Format_RGB32
QVideoFrame::Format_RGB244The frame is stored using a 24-bit RGB format (8-8-8). This is equivalent to QImage::Format_RGB888
QVideoFrame::Format_RGB5655The frame is stored using a 16-bit RGB format (5-6-5). This is equivalent to QImage::Format_RGB16.
QVideoFrame::Format_RGB5556The frame is stored using a 16-bit RGB format (5-5-5). This is equivalent to QImage::Format_RGB555.
QVideoFrame::Format_ARGB8565_Premultiplied7The frame is stored using a 24-bit premultiplied ARGB format (8-5-6-5).
QVideoFrame::Format_BGRA328The frame is stored using a 32-bit BGRA format (0xBBGGRRAA).
QVideoFrame::Format_BGRA32_Premultiplied9The frame is stored using a premultiplied 32bit BGRA format.
QVideoFrame::Format_ABGR3233The frame is stored using a 32-bit ABGR format (0xAABBGGRR).
QVideoFrame::Format_BGR3210The frame is stored using a 32-bit BGR format (0xBBGGRRff).
QVideoFrame::Format_BGR2411The frame is stored using a 24-bit BGR format (0xBBGGRR).
QVideoFrame::Format_BGR56512The frame is stored using a 16-bit BGR format (5-6-5).
QVideoFrame::Format_BGR55513The frame is stored using a 16-bit BGR format (5-5-5).
QVideoFrame::Format_BGRA5658_Premultiplied14The frame is stored using a 24-bit premultiplied BGRA format (5-6-5-8).
QVideoFrame::Format_AYUV44415The frame is stored using a packed 32-bit AYUV format (0xAAYYUUVV).
QVideoFrame::Format_AYUV444_Premultiplied16The frame is stored using a packed premultiplied 32-bit AYUV format (0xAAYYUUVV).
QVideoFrame::Format_YUV44417The frame is stored using a 24-bit packed YUV format (8-8-8).
QVideoFrame::Format_YUV420P18The frame is stored using an 8-bit per component planar YUV format with the U and V planes horizontally and vertically sub-sampled, i.e. the height and width of the U and V planes are half that of the Y plane.
QVideoFrame::Format_YUV422P34The frame is stored using an 8-bit per component planar YUV format with the U and V planes horizontally sub-sampled, i.e. the width of the U and V planes are half that of the Y plane, and height of U and V planes is the same as Y.
QVideoFrame::Format_YV1219The frame is stored using an 8-bit per component planar YVU format with the V and U planes horizontally and vertically sub-sampled, i.e. the height and width of the V and U planes are half that of the Y plane.
QVideoFrame::Format_UYVY20The frame is stored using an 8-bit per component packed YUV format with the U and V planes horizontally sub-sampled (U-Y-V-Y), i.e. two horizontally adjacent pixels are stored as a 32-bit macropixel which has a Y value for each pixel and common U and V values.
QVideoFrame::Format_YUYV21The frame is stored using an 8-bit per component packed YUV format with the U and V planes horizontally sub-sampled (Y-U-Y-V), i.e. two horizontally adjacent pixels are stored as a 32-bit macropixel which has a Y value for each pixel and common U and V values.
QVideoFrame::Format_NV1222The frame is stored using an 8-bit per component semi-planar YUV format with a Y plane (Y) followed by a horizontally and vertically sub-sampled, packed UV plane (U-V).
QVideoFrame::Format_NV2123The frame is stored using an 8-bit per component semi-planar YUV format with a Y plane (Y) followed by a horizontally and vertically sub-sampled, packed VU plane (V-U).
QVideoFrame::Format_IMC124The frame is stored using an 8-bit per component planar YUV format with the U and V planes horizontally and vertically sub-sampled. This is similar to the Format_YUV420P type, except that the bytes per line of the U and V planes are padded out to the same stride as the Y plane.
QVideoFrame::Format_IMC225The frame is stored using an 8-bit per component planar YUV format with the U and V planes horizontally and vertically sub-sampled. This is similar to the Format_YUV420P type, except that the lines of the U and V planes are interleaved, i.e. each line of U data is followed by a line of V data creating a single line of the same stride as the Y data.
QVideoFrame::Format_IMC326The frame is stored using an 8-bit per component planar YVU format with the V and U planes horizontally and vertically sub-sampled. This is similar to the Format_YV12 type, except that the bytes per line of the V and U planes are padded out to the same stride as the Y plane.
QVideoFrame::Format_IMC427The frame is stored using an 8-bit per component planar YVU format with the V and U planes horizontally and vertically sub-sampled. This is similar to the Format_YV12 type, except that the lines of the V and U planes are interleaved, i.e. each line of V data is followed by a line of U data creating a single line of the same stride as the Y data.
QVideoFrame::Format_Y828The frame is stored using an 8-bit greyscale format.
QVideoFrame::Format_Y1629The frame is stored using a 16-bit linear greyscale format. Little endian.
QVideoFrame::Format_Jpeg30The frame is stored in compressed Jpeg format.
QVideoFrame::Format_CameraRaw31The frame is stored using a device specific camera raw format.
QVideoFrame::Format_AdobeDng32The frame is stored using raw Adobe Digital Negative (DNG) format.
QVideoFrame::Format_User1000Start value for user defined pixel formats.