This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Migration
Migrating to UNIGINE 2.0
C++ API Migration
Migrating from UNIGINE 2.0 to UNIGINE 2.1
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

Current Viewport Grabbing with AppGrabber Plugin

The AppGrabber plugin takes a snapshot of the current viewport each frame. Each snapshot is put in the internal Image and can be obtained via the engine.grabber.getImage() function. Then you can use this snapshot for any purpose: for recording a video, for streaming data to broadcasting applications and so on.

The AppGrabber enables to specify a resolution of the grabbed snapshot (up to 4K), independently on the current window resolution. To set the required output resolution, you should specify additional options on the application start-up. Also the plugin enables grabbing the current viewport with or without the main GUI of the application.

Usage Example

To get a snapshot of the viewport in the current frame and then save it to a file, call the engine.grabber.getImage() function in the world script update() function:

Source code (UnigineScript)
#ifdef HAS_APP_GRABBER
int update() {
	
	// grab the viewport in the current frame
	Image image = engine.grabber.getImage();
	// save the grabbed image to a file
	if(image != NULL) image.save("grabber.png");
	
	return 1;
}

int init() {
	
	// add nodes to the scene here
	
	return 1;
}
#endif
When you quit the world, the grabber.dds file will contain the snapshot of the viewport in the last frame.

See Also

  • engine.grabber Functions
  • A data/samples/plugins/app_grabber_00 sample that demonstrates how to get snapshots of the viewport and save them asynchronously.

Launching AppGrabber

To use this plugin, specify the extern_plugin command-line option together with the required start-up options on the application start-up, for example:

Shell commands
main_x86d -data_path "../" -extern_plugin AppGrabber

AppGrabber Options

The following CLI options can be specified on the application start-up:

  • grabber_width - width of the grabbed snapshot.
  • grabber_height - height of the grabbed snapshot.
  • grabber_gui - value indicating whether the main GUI should be grabbed or not:
    • 1 - the main GUI of the application will be grabbed.
    • 0 - the main GUI won't be grabbed (default).

For example, to grab the current viewport together with the main GUI, you should specify the following in the command-line:

Shell commands
main_x86d -data_path "../" -extern_plugin AppGrabber -grabber_gui 1
The following image will be grabbed in the result:

Streaming Data with AppGrabber

The AppGrabber plugin can be used for streaming data to a broadcasting application.

The broadcasting application is usually implemented by using interfaces (APIs) that are provided by a developer SDK of a capture and playback card (DeckLink, for example). This application receives a video stream and processes it. For example, it can receive different video streams from different sources and mix them.

To send a video stream from the engine to such application, you can use one of the following ways:

  • Export all the required functions from the broadcasting application to UnigineScript and send an image grabbed by AppGrabber to this functions each frame.
  • Directly modify the source code of the AppGrabber plugin in order to use it as a base for the broadcasting application.
Last update: 03.07.2017
Build: ()