|  | Home · All Classes · Modules

# QVideoSurfaceFormat Class Reference
[QtMultimedia module]

The QVideoSurfaceFormat class specifies the stream format of a video presentation surface. More...

### Types

- enum Direction { TopToBottom, BottomToTop }
- enum YCbCrColorSpace { YCbCr_Undefined, YCbCr_BT601, YCbCr_BT709, YCbCr_xvYCC601, YCbCr_xvYCC709, YCbCr_JPEG }

### Methods

- __init__ (self)
- __init__ (self, QSize size, QVideoFrame.PixelFormat format, QAbstractVideoBuffer.HandleType type = QAbstractVideoBuffer.NoHandle)
- __init__ (self, QVideoSurfaceFormat format)
- int frameHeight (self)
- float frameRate (self)
- QSize frameSize (self)
- int frameWidth (self)
- QAbstractVideoBuffer.HandleType handleType (self)
- bool isValid (self)
- QSize pixelAspectRatio (self)
- QVideoFrame.PixelFormat pixelFormat (self)
- QVariant property (self, str name)
- list-of-QByteArray propertyNames (self)
- Direction scanLineDirection (self)
- setFrameRate (self, float rate)
- setFrameSize (self, QSize size)
- setFrameSize (self, int width, int height)
- setPixelAspectRatio (self, QSize ratio)
- setPixelAspectRatio (self, int width, int height)
- setProperty (self, str name, QVariant value)
- setScanLineDirection (self, Direction direction)
- setViewport (self, QRect viewport)
- setYCbCrColorSpace (self, YCbCrColorSpace colorSpace)
- QSize sizeHint (self)
- QRect viewport (self)
- YCbCrColorSpace yCbCrColorSpace (self)

### Special Methods

- bool __eq__ (self, QVideoSurfaceFormat format)
- bool __ne__ (self, QVideoSurfaceFormat format)

## Detailed Description

The QVideoSurfaceFormat class specifies the stream format of a video presentation surface.

A video surface presents a stream of video frames. The surface's format describes the type of the frames and determines how they should be presented.

The core properties of a video stream required to setup a video surface are the pixel format given by pixelFormat(), and the frame dimensions given by frameSize().

If the surface is to present frames using a frame's handle a surface format will also include a handle type which is given by the handleType() function.

The region of a frame that is actually displayed on a video surface is given by the viewport(). A stream may have a viewport less than the entire region of a frame to allow for videos smaller than the nearest optimal size of a video frame. For example the width of a frame may be extended so that the start of each scan line is eight byte aligned.

Other common properties are the pixelAspectRatio(), scanLineDirection(), and frameRate(). Additionally a stream may have some additional type specific properties which are listed by the dynamicPropertyNames() function and can be accessed using the property(), and setProperty() functions.

## Type Documentation

### QVideoSurfaceFormat.Direction

Enumerates the layout direction of video scan lines.

Constant | Value | Description
--- | --- | ---
`QVideoSurfaceFormat.TopToBottom` | `0` | Scan lines are arranged from the top of the frame to the bottom.
`QVideoSurfaceFormat.BottomToTop` | `1` | Scan lines are arranged from the bottom of the frame to the top.

### QVideoSurfaceFormat.YCbCrColorSpace

Enumerates the Y'CbCr color space of video frames.

Constant | Value | Description
--- | --- | ---
`QVideoSurfaceFormat.YCbCr_Undefined` | `0` | No color space is specified.
`QVideoSurfaceFormat.YCbCr_BT601` | `1` | A Y'CbCr color space defined by ITU-R recommendation BT.601 with Y value range from 16 to 235, and Cb/Cr range from 16 to 240. Used in standard definition video.
`QVideoSurfaceFormat.YCbCr_BT709` | `2` | A Y'CbCr color space defined by ITU-R BT.709 with the same values range as YCbCr_BT601. Used for HDTV.
`QVideoSurfaceFormat.YCbCr_xvYCC601` | `3` | The BT.601 color space with the value range extended to 0 to 255. It is backward compatibile with BT.601 and uses values outside BT.601 range to represent wider colors range.
`QVideoSurfaceFormat.YCbCr_xvYCC709` | `4` | The BT.709 color space with the value range extended to 0 to 255.
`QVideoSurfaceFormat.YCbCr_JPEG` | `5` | The full range Y'CbCr color space used in JPEG files.

## Method Documentation

### QVideoSurfaceFormat.__init__ (self)

Constructs a null video stream format.

### QVideoSurfaceFormat.__init__ (self, QSize size, QVideoFrame.PixelFormat format, QAbstractVideoBuffer.HandleType type = QAbstractVideoBuffer.NoHandle)

Contructs a description of stream which receives stream of type buffers with given frame size and pixel format.

### QVideoSurfaceFormat.__init__ (self, QVideoSurfaceFormat format)

Constructs a copy of other.

### int QVideoSurfaceFormat.frameHeight (self)

Returns the height of frame in a video stream.

### float QVideoSurfaceFormat.frameRate (self)

Returns the frame rate of a video stream in frames per second.

See also setFrameRate().

### QSize QVideoSurfaceFormat.frameSize (self)

Returns the size of frames in a video stream.

See also setFrameSize(), frameWidth(), and frameHeight().

### int QVideoSurfaceFormat.frameWidth (self)

Returns the width of frames in a video stream.

See also frameSize() and frameHeight().

### QAbstractVideoBuffer.HandleType QVideoSurfaceFormat.handleType (self)

Returns the type of handle the surface uses to present the frame data.

If the handle type is QAbstractVideoBuffer.NoHandle buffers with any handle type are valid provided they can be mapped with the QAbstractVideoBuffer.ReadOnly flag. If the handleType() is not QAbstractVideoBuffer.NoHandle then the handle type of the buffer be the same as that of the surface format.

### bool QVideoSurfaceFormat.isValid (self)

Identifies if a video surface format has a valid pixel format and frame size.

Returns true if the format is valid, and false otherwise.

### QSize QVideoSurfaceFormat.pixelAspectRatio (self)

Returns a video stream's pixel aspect ratio.

See also setPixelAspectRatio().

### QVideoFrame.PixelFormat QVideoSurfaceFormat.pixelFormat (self)

Returns the pixel format of frames in a video stream.

### QVariant QVideoSurfaceFormat.property (self, str name)

Returns the value of the video format's name property.

See also setProperty().

### list-of-QByteArray QVideoSurfaceFormat.propertyNames (self)

Returns a list of video format dynamic property names.

### Direction QVideoSurfaceFormat.scanLineDirection (self)

Returns the direction of scan lines.

See also setScanLineDirection().

### QVideoSurfaceFormat.setFrameRate (self, float rate)

Sets the frame rate of a video stream in frames per second.

See also frameRate().

### QVideoSurfaceFormat.setFrameSize (self, QSize size)

Sets the size of frames in a video stream to size.

This will reset the viewport() to fill the entire frame.

See also frameSize().

### QVideoSurfaceFormat.setFrameSize (self, int width, int height)

This is an overloaded function.

Sets the width and height of frames in a video stream.

This will reset the viewport() to fill the entire frame.

### QVideoSurfaceFormat.setPixelAspectRatio (self, QSize ratio)

Sets a video stream's pixel aspect ratio.

See also pixelAspectRatio().

### QVideoSurfaceFormat.setPixelAspectRatio (self, int width, int height)

This is an overloaded function.

Sets the horizontal and vertical elements of a video stream's pixel aspect ratio.

### QVideoSurfaceFormat.setProperty (self, str name, QVariant value)

Sets the video format's name property to value.

See also property().

### QVideoSurfaceFormat.setScanLineDirection (self, Direction direction)

Sets the direction of scan lines.

See also scanLineDirection().

### QVideoSurfaceFormat.setViewport (self, QRect viewport)

Sets the viewport of a video stream to viewport.

See also viewport().

### QVideoSurfaceFormat.setYCbCrColorSpace (self, YCbCrColorSpace colorSpace)

Sets the Y'CbCr color space of a video stream. It is only used with raw YUV frame types.

See also yCbCrColorSpace().

### QSize QVideoSurfaceFormat.sizeHint (self)

Returns a suggested size in pixels for the video stream.

This is the size of the viewport scaled according to the pixel aspect ratio.

### QRect QVideoSurfaceFormat.viewport (self)

Returns the viewport of a video stream.

The viewport is the region of a video frame that is actually displayed.

By default the viewport covers an entire frame.

See also setViewport().

### YCbCrColorSpace QVideoSurfaceFormat.yCbCrColorSpace (self)

Returns the Y'CbCr color space of a video stream.

See also setYCbCrColorSpace().

### bool QVideoSurfaceFormat.__eq__ (self, QVideoSurfaceFormat format)

### bool QVideoSurfaceFormat.__ne__ (self, QVideoSurfaceFormat format)