Screen Recording in UnityMolX: Screenshots and Videos

Table of Contents

1. Screenshots

UnityMol provides a simple way to capture a screenshot using the command line or with the Save Image button:

screenshot("/path/to/capture.png", 1920, 1080, transparentBG=False)

You can define the size of the image you want to render by changing the resolution in terms of width and height, given in pixels.

⚠️ Note: recording pictures with transparent background takes more time than a simple capture.

2. Video

The video recording in UnityMol is based on FFMPEG and this repo. Parts of FFMPEG are licensed under the GPL. See this page for legal considerations.

The rendered video has a fixed resolution and framerate that you can set from the APIPython command interpreter:

startVideo("/path/to/captureVid.mp4", 1920, 1080, 30)
#... do things ...
stopVideo()

One can pause and unpause the video to perform some actions (moving molecules / changing representations / loading …) without recording the intermediate states as follows:

pauseVideo()
unpauseVideo()

One can also combine the pause/unpause features with coroutines to wait for a certain amount of time or frames. See an example script implementing this approach here.

Author: Marc Baaden

Created: 2025-12-03 Mer 19:03

Validate