unreal.MediaCapture

class unreal.MediaCapture(outer=None, name='None')

Bases: unreal.Object

Abstract base class for media capture.

MediaCapture capture the texture of the Render target or the SceneViewport and sends it to an external media device. MediaCapture should be created by a MediaOutput.

C++ Source:

  • Plugin: MediaIOFramework
  • Module: MediaIOCore
  • File: MediaCapture.h

Editor Properties: (see get_editor_property/set_editor_property)

  • on_state_changed (MediaCaptureStateChangedSignature): [Read-Write] Called when the state of the capture changed.
capture_active_scene_viewport(capture_options) → bool

Stop the current capture if there is one. Then find and capture every frame from active SceneViewport. It can only find a SceneViewport when you play in Standalone or in “New Editor Window PIE”. If the active SceneViewport is destroyed, the capture will stop. The SceneViewport needs to be of the same size and have the same pixel format as requested by the media output.

Parameters:capture_options (MediaCaptureOptions) –
Returns:True if the capture was successfully started
Return type:bool
capture_texture_render_target2d(render_target, capture_options) → bool

Stop the actual capture if there is one. Then capture every frame for a TextureRenderTarget2D. The TextureRenderTarget2D needs to be of the same size and have the same pixel format as requested by the media output.

Parameters:
Returns:

True if the capture was successfully started

Return type:

bool

get_desired_pixel_format() → PixelFormat

Get the desired pixel format of the current capture.

Returns:
Return type:PixelFormat
get_desired_size() → IntPoint

Get the desired size of the current capture.

Returns:
Return type:IntPoint
get_state() → MediaCaptureState

Get the current state of the capture.

Returns:
Return type:MediaCaptureState
on_state_changed

(MediaCaptureStateChangedSignature) – [Read-Write] Called when the state of the capture changed.

set_media_output(media_output) → None

Set the media output. Can only be set when the capture is stopped.

Parameters:media_output (MediaOutput) –
stop_capture(allow_pending_frame_to_be_process) → None

Stop the previous requested capture.

Parameters:allow_pending_frame_to_be_process (bool) – Keep copying the pending frames asynchronously or stop immediately without copying the pending frames.
update_texture_render_target2d(render_target) → bool

Update the current capture with every frame for a TextureRenderTarget2D. The TextureRenderTarget2D needs to be of the same size and have the same pixel format as requested by the media output.

Parameters:render_target (TextureRenderTarget2D) –
Returns:Return true if the capture was successfully updated. If false is returned, the capture was stopped.
Return type:bool