GstVideo.VideoOverlayComposition

Fields

None

Methods

class

new (rectangle)

add_rectangle (rectangle)

blend (video_buf)

copy ()

get_rectangle (n)

get_seqnum ()

make_writable ()

n_rectangles ()

Details

class GstVideo.VideoOverlayComposition

Functions to create and handle overlay compositions on video buffers.

An overlay composition describes one or more overlay rectangles to be blended on top of a video buffer.

This API serves two main purposes:

  • it can be used to attach overlay information (subtitles or logos) to non-raw video buffers such as GL/VAAPI/VDPAU surfaces. The actual blending of the overlay can then be done by e.g. the video sink that processes these non-raw buffers.

  • it can also be used to blend overlay rectangles on top of raw video buffers, thus consolidating blending functionality for raw video in one place.

Together, this allows existing overlay elements to easily handle raw and non-raw video as input in without major changes (once the overlays have been put into a GstVideo.VideoOverlayComposition object anyway) - for raw video the overlay can just use the blending function to blend the data on top of the video, and for surface buffers it can just attach them to the buffer and let the sink render the overlays.

classmethod new(rectangle)[source]
Parameters:

rectangle (GstVideo.VideoOverlayRectangle or None) – a GstVideo.VideoOverlayRectangle to add to the composition

Returns:

a new GstVideo.VideoOverlayComposition. Unref with gst_video_overlay_composition_unref() when no longer needed.

Return type:

GstVideo.VideoOverlayComposition

Creates a new video overlay composition object to hold one or more overlay rectangles.

Note that since 1.20 this allows to pass None for rectangle.

add_rectangle(rectangle)[source]
Parameters:

rectangle (GstVideo.VideoOverlayRectangle) – a GstVideo.VideoOverlayRectangle to add to the composition

Adds an overlay rectangle to an existing overlay composition object. This must be done right after creating the overlay composition.

blend(video_buf)[source]
Parameters:

video_buf (GstVideo.VideoFrame) – a GstVideo.VideoFrame containing raw video data in a supported format. It should be mapped using Gst.MAP_READWRITE

Return type:

bool

Blends the overlay rectangles in self on top of the raw video data contained in video_buf. The data in video_buf must be writable and mapped appropriately.

Since video_buf data is read and will be modified, it ought be mapped with flag Gst.MAP_READWRITE.

copy()[source]
Returns:

a new GstVideo.VideoOverlayComposition equivalent to self.

Return type:

GstVideo.VideoOverlayComposition

Makes a copy of self and all contained rectangles, so that it is possible to modify the composition and contained rectangles (e.g. add additional rectangles or change the render co-ordinates or render dimension). The actual overlay pixel data buffers contained in the rectangles are not copied.

get_rectangle(n)[source]
Parameters:

n (int) – number of the rectangle to get

Returns:

the n-th rectangle, or None if n is out of bounds. Will not return a new reference, the caller will need to obtain her own reference using gst_video_overlay_rectangle_ref() if needed.

Return type:

GstVideo.VideoOverlayRectangle or None

Returns the n-th GstVideo.VideoOverlayRectangle contained in self.

get_seqnum()[source]
Returns:

the sequence number of self

Return type:

int

Returns the sequence number of this composition. Sequence numbers are monotonically increasing and unique for overlay compositions and rectangles (meaning there will never be a rectangle with the same sequence number as a composition).

make_writable()[source]
Returns:

a writable GstVideo.VideoOverlayComposition equivalent to self.

Return type:

GstVideo.VideoOverlayComposition

Takes ownership of self and returns a version of self that is writable (i.e. can be modified). Will either return self right away, or create a new writable copy of self and unref self itself. All the contained rectangles will also be copied, but the actual overlay pixel data buffers contained in the rectangles are not copied.

n_rectangles()[source]
Returns:

the number of rectangles

Return type:

int

Returns the number of GstVideo.VideoOverlayRectangle s contained in self.