GstVideo.VideoOverlayRectangle

Fields

None

Methods

class

new_raw (pixels, render_x, render_y, render_width, render_height, flags)

copy ()

get_flags ()

get_global_alpha ()

get_pixels_argb (flags)

get_pixels_ayuv (flags)

get_pixels_raw (flags)

get_pixels_unscaled_argb (flags)

get_pixels_unscaled_ayuv (flags)

get_pixels_unscaled_raw (flags)

get_render_rectangle ()

get_seqnum ()

set_global_alpha (global_alpha)

set_render_rectangle (render_x, render_y, render_width, render_height)

Details

class GstVideo.VideoOverlayRectangle

An opaque video overlay rectangle object. A rectangle contains a single overlay rectangle which can be added to a composition.

classmethod new_raw(pixels, render_x, render_y, render_width, render_height, flags)
Parameters:
  • pixels (Gst.Buffer) – a Gst.Buffer pointing to the pixel memory

  • render_x (int) – the X co-ordinate on the video where the top-left corner of this overlay rectangle should be rendered to

  • render_y (int) – the Y co-ordinate on the video where the top-left corner of this overlay rectangle should be rendered to

  • render_width (int) – the render width of this rectangle on the video

  • render_height (int) – the render height of this rectangle on the video

  • flags (GstVideo.VideoOverlayFormatFlags) – flags

Returns:

a new GstVideo.VideoOverlayRectangle. Unref with gst_video_overlay_rectangle_unref() when no longer needed.

Return type:

GstVideo.VideoOverlayRectangle

Creates a new video overlay rectangle with ARGB or AYUV pixel data. The layout in case of ARGB of the components in memory is B-G-R-A on little-endian platforms (corresponding to GstVideo.VideoFormat.BGRA) and A-R-G-B on big-endian platforms (corresponding to GstVideo.VideoFormat.ARGB). In other words, pixels are treated as 32-bit words and the lowest 8 bits then contain the blue component value and the highest 8 bits contain the alpha component value. Unless specified in the flags, the RGB values are non-premultiplied. This is the format that is used by most hardware, and also many rendering libraries such as Cairo, for example. The pixel data buffer must have GstVideo.VideoMeta set.

copy()
Returns:

a new GstVideo.VideoOverlayRectangle equivalent to self.

Return type:

GstVideo.VideoOverlayRectangle

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

get_flags()
Returns:

the GstVideo.VideoOverlayFormatFlags associated with the rectangle.

Return type:

GstVideo.VideoOverlayFormatFlags

Retrieves the flags associated with a GstVideo.VideoOverlayRectangle. This is useful if the caller can handle both premultiplied alpha and non premultiplied alpha, for example. By knowing whether the rectangle uses premultiplied or not, it can request the pixel data in the format it is stored in, to avoid unnecessary conversion.

get_global_alpha()
Returns:

the global-alpha value associated with the rectangle.

Return type:

float

Retrieves the global-alpha value associated with a GstVideo.VideoOverlayRectangle.

get_pixels_argb(flags)
Parameters:

flags (GstVideo.VideoOverlayFormatFlags) – flags If a global_alpha value != 1 is set for the rectangle, the caller should set the GstVideo.VideoOverlayFormatFlags.GLOBAL_ALPHA flag if he wants to apply global-alpha himself. If the flag is not set global_alpha is applied internally before returning the pixel-data.

Returns:

a Gst.Buffer holding the ARGB pixel data with width and height of the render dimensions as per GstVideo.VideoOverlayRectangle.get_render_rectangle(). This function does not return a reference, the caller should obtain a reference of her own with gst_buffer_ref() if needed.

Return type:

Gst.Buffer

get_pixels_ayuv(flags)
Parameters:

flags (GstVideo.VideoOverlayFormatFlags) – flags If a global_alpha value != 1 is set for the rectangle, the caller should set the GstVideo.VideoOverlayFormatFlags.GLOBAL_ALPHA flag if he wants to apply global-alpha himself. If the flag is not set global_alpha is applied internally before returning the pixel-data.

Returns:

a Gst.Buffer holding the AYUV pixel data with width and height of the render dimensions as per GstVideo.VideoOverlayRectangle.get_render_rectangle(). This function does not return a reference, the caller should obtain a reference of her own with gst_buffer_ref() if needed.

Return type:

Gst.Buffer

get_pixels_raw(flags)
Parameters:

flags (GstVideo.VideoOverlayFormatFlags) – flags If a global_alpha value != 1 is set for the rectangle, the caller should set the GstVideo.VideoOverlayFormatFlags.GLOBAL_ALPHA flag if he wants to apply global-alpha himself. If the flag is not set global_alpha is applied internally before returning the pixel-data.

Returns:

a Gst.Buffer holding the pixel data with format as originally provided and specified in video meta with width and height of the render dimensions as per GstVideo.VideoOverlayRectangle.get_render_rectangle(). This function does not return a reference, the caller should obtain a reference of her own with gst_buffer_ref() if needed.

Return type:

Gst.Buffer

get_pixels_unscaled_argb(flags)
Parameters:

flags (GstVideo.VideoOverlayFormatFlags) – flags. If a global_alpha value != 1 is set for the rectangle, the caller should set the GstVideo.VideoOverlayFormatFlags.GLOBAL_ALPHA flag if he wants to apply global-alpha himself. If the flag is not set global_alpha is applied internally before returning the pixel-data.

Returns:

a Gst.Buffer holding the ARGB pixel data with GstVideo.VideoMeta set. This function does not return a reference, the caller should obtain a reference of her own with gst_buffer_ref() if needed.

Return type:

Gst.Buffer

Retrieves the pixel data as it is. This is useful if the caller can do the scaling itself when handling the overlaying. The rectangle will need to be scaled to the render dimensions, which can be retrieved using GstVideo.VideoOverlayRectangle.get_render_rectangle().

get_pixels_unscaled_ayuv(flags)
Parameters:

flags (GstVideo.VideoOverlayFormatFlags) – flags. If a global_alpha value != 1 is set for the rectangle, the caller should set the GstVideo.VideoOverlayFormatFlags.GLOBAL_ALPHA flag if he wants to apply global-alpha himself. If the flag is not set global_alpha is applied internally before returning the pixel-data.

Returns:

a Gst.Buffer holding the AYUV pixel data with GstVideo.VideoMeta set. This function does not return a reference, the caller should obtain a reference of her own with gst_buffer_ref() if needed.

Return type:

Gst.Buffer

Retrieves the pixel data as it is. This is useful if the caller can do the scaling itself when handling the overlaying. The rectangle will need to be scaled to the render dimensions, which can be retrieved using GstVideo.VideoOverlayRectangle.get_render_rectangle().

get_pixels_unscaled_raw(flags)
Parameters:

flags (GstVideo.VideoOverlayFormatFlags) – flags. If a global_alpha value != 1 is set for the rectangle, the caller should set the GstVideo.VideoOverlayFormatFlags.GLOBAL_ALPHA flag if he wants to apply global-alpha himself. If the flag is not set global_alpha is applied internally before returning the pixel-data.

Returns:

a Gst.Buffer holding the pixel data with GstVideo.VideoMeta set. This function does not return a reference, the caller should obtain a reference of her own with gst_buffer_ref() if needed.

Return type:

Gst.Buffer

Retrieves the pixel data as it is. This is useful if the caller can do the scaling itself when handling the overlaying. The rectangle will need to be scaled to the render dimensions, which can be retrieved using GstVideo.VideoOverlayRectangle.get_render_rectangle().

get_render_rectangle()
Returns:

True if valid render dimensions were retrieved.

render_x:

address where to store the X render offset

render_y:

address where to store the Y render offset

render_width:

address where to store the render width

render_height:

address where to store the render height

Return type:

(bool, render_x: int, render_y: int, render_width: int, render_height: int)

Retrieves the render position and render dimension of the overlay rectangle on the video.

get_seqnum()
Returns:

the sequence number of self

Return type:

int

Returns the sequence number of this rectangle. 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).

Using the sequence number of a rectangle as an indicator for changed pixel-data of a rectangle is dangereous. Some API calls, like e.g. GstVideo.VideoOverlayRectangle.set_global_alpha(), automatically update the per rectangle sequence number, which is misleading for renderers/ consumers, that handle global-alpha themselves. For them the pixel-data returned by gst_video_overlay_rectangle_get_pixels_*() won’t be different for different global-alpha values. In this case a renderer could also use the Gst.Buffer pointers as a hint for changed pixel-data.

set_global_alpha(global_alpha)
Parameters:

global_alpha (float) – Global alpha value (0 to 1.0)

Sets the global alpha value associated with a GstVideo.VideoOverlayRectangle. Per- pixel alpha values are multiplied with this value. Valid values: 0 <= global_alpha <= 1; 1 to deactivate.

self must be writable, meaning its refcount must be 1. You can make the rectangles inside a GstVideo.VideoOverlayComposition writable using GstVideo.VideoOverlayComposition.make_writable() or GstVideo.VideoOverlayComposition.copy().

set_render_rectangle(render_x, render_y, render_width, render_height)
Parameters:
  • render_x (int) – render X position of rectangle on video

  • render_y (int) – render Y position of rectangle on video

  • render_width (int) – render width of rectangle

  • render_height (int) – render height of rectangle

Sets the render position and dimensions of the rectangle on the video. This function is mainly for elements that modify the size of the video in some way (e.g. through scaling or cropping) and need to adjust the details of any overlays to match the operation that changed the size.

self must be writable, meaning its refcount must be 1. You can make the rectangles inside a GstVideo.VideoOverlayComposition writable using GstVideo.VideoOverlayComposition.make_writable() or GstVideo.VideoOverlayComposition.copy().