内容表

上一话题

QAbstractVideoFilter

下一话题

QAudio

QAbstractVideoSurface

QAbstractVideoSurface class is a base class for video presentation surfaces. 更多

Inheritance diagram of PySide2.QtMultimedia.QAbstractVideoSurface

概要

函数

虚函数

详细描述

QAbstractVideoSurface class defines the standard interface that video producers use to inter-operate with video presentation surfaces. You can subclass this interface to receive video frames from sources like decoded media or cameras 以履行你自己的处理。

视频表面呈现连续流同等格式 QVideoFrame 实例,每帧格式兼容流供给格式当开始呈现时。每帧可以拥有时间戳信息,可以用于表面以决定何时显示该帧。

表面能呈现的像素列表格式,给出通过 supportedPixelFormats() function, and the isFormatSupported() function will test if a video surface format is supported. If a format is not supported the nearestFormat() function may be able to suggest a similar format. For example, if a surface supports fixed set of resolutions it may suggest the smallest supported resolution that contains the proposed resolution.

start() function takes a supported format and enables a video surface. Once started a surface will begin displaying the frames it receives in the present() function. Surfaces may hold a reference to the buffer of a presented video frame until a new frame is presented or streaming is stopped. In addition, a video surface may hold a reference to a video frame until the end timestamp 被传递。 stop() function will disable a surface and release any video buffers it holds references to.

实现 QAbstractVideoSurface 子类

在实现该接口的子类时,只有少数函数要实现,分成两类:

  • 格式相关

  • 呈现相关

对于格式相关功能,仅仅必须描述支持的像素格式 (和 nearestFormat() function). For presentation related functionality, you have to implement the present() function, and the start() and stop() 函数。

注意

必须调用基类实现的 start() and stop() in your implementation.

class QAbstractVideoSurface ( [ parent=None ] )
param parent

QObject

构造视频表面采用给定 parent .

PySide2.QtMultimedia.QAbstractVideoSurface. Error

此枚举描述可能的错误,错误返回通过 error() 函数。

常量

描述

QAbstractVideoSurface.NoError

没有发生错误。

QAbstractVideoSurface.UnsupportedFormatError

视频格式不被支持。

QAbstractVideoSurface.IncorrectFormatError

视频帧不兼容表面格式。

QAbstractVideoSurface.StoppedError

表面尚未开始。

QAbstractVideoSurface.ResourceError

表面无法分配一些资源。

PySide2.QtMultimedia.QAbstractVideoSurface. activeChanged ( active )
参数

active bool

PySide2.QtMultimedia.QAbstractVideoSurface. error ( )
返回类型

Error

返回上次发生的错误。

If a surface fails to start() , or stops unexpectedly this function can be called to discover what error occurred.

另请参阅

setError()

PySide2.QtMultimedia.QAbstractVideoSurface. isActive ( )
返回类型

bool

指示视频表面是否已启动。

返回 true 若表面已启动,否则返回 false。

PySide2.QtMultimedia.QAbstractVideoSurface. isFormatSupported ( format )
参数

format QVideoSurfaceFormat

返回类型

bool

测试视频表面 format 以确定表面是否能接受它。

返回 true,若格式被表面支持,否则,返回 false。

PySide2.QtMultimedia.QAbstractVideoSurface. nativeResolution ( )
返回类型

QSize

PySide2.QtMultimedia.QAbstractVideoSurface. nativeResolutionChanged ( resolution )
参数

resolution QSize

PySide2.QtMultimedia.QAbstractVideoSurface. nearestFormat ( format )
参数

format QVideoSurfaceFormat

返回类型

QVideoSurfaceFormat

返回所支持的视频表面格式,类似于 format .

A similar surface format is one that has the same pixel format and handle type but may differ in some of the other properties. For example, if there are restrictions on the frame sizes a video surface can accept it may suggest a format with a larger frame size and a 视口 the size of the original frame size.

If the format is already supported it will be returned unchanged, or if there is no similar supported format an invalid format will be returned.

PySide2.QtMultimedia.QAbstractVideoSurface. present ( frame )
参数

frame QVideoFrame

返回类型

bool

呈现视频 frame .

返回 true,若帧被呈现;返回 false,若发生错误。

Not all surfaces will block until the presentation of a frame has completed. Calling on a non-blocking surface may fail if called before the presentation of a previous frame has completed. In such cases the surface may not return to a ready state until it has had an opportunity to process events.

If fails for any other reason the surface should immediately enter the stopped state and an error() value will be set.

A video surface must be in the started state for to succeed, and the format of the video frame must be compatible with the current video surface format.

另请参阅

error()

PySide2.QtMultimedia.QAbstractVideoSurface. setError ( error )
参数

error Error

设置值为 error() to error .

此接口的实现者可以调用这,以传达最近错误是什么。

另请参阅

error()

PySide2.QtMultimedia.QAbstractVideoSurface. setNativeResolution ( resolution )
参数

resolution QSize

设置视频表面的原始 resolution .

This function can be called by implementors of this interface to specify to frame producers what the native resolution of this surface is.

PySide2.QtMultimedia.QAbstractVideoSurface. start ( format )
参数

format QVideoSurfaceFormat

返回类型

bool

使视频表面开始呈现 format 帧。

返回 true,若表面已开始;返回 false,若发生错误。

注意

You must call the base class implementation of at the end of your implementation.

PySide2.QtMultimedia.QAbstractVideoSurface. stop ( )

停止在视频表面呈现帧,并释放任何获得资源在 start() .

注意

You must call the base class implementation of at the start of your implementation.

PySide2.QtMultimedia.QAbstractVideoSurface. supportedFormatsChanged ( )
PySide2.QtMultimedia.QAbstractVideoSurface. supportedPixelFormats ( [ type=QAbstractVideoBuffer.NoHandle ] )
参数

type HandleType

返回类型

返回视频表面能呈现的像素格式列表,针对给定句柄 type .

返回像素格式为 NoHandle 类型是有效的,对于能以只读方式映射的任何缓冲。

可假定列表中的首个类型,渲染会更快。

PySide2.QtMultimedia.QAbstractVideoSurface. surfaceFormat ( )
返回类型

QVideoSurfaceFormat

返回视频表面的格式。

PySide2.QtMultimedia.QAbstractVideoSurface. surfaceFormatChanged ( format )
参数

format QVideoSurfaceFormat