Panda3d-screenrecorder Easy Realtime Video Encoding from Panda3D

Here I present panda3d-screenrecorder , an engine native, non-blocking, offline screen recorder that will take your ShowBase instance and set up an instant replay type capture system, with a single pandarecord.setup_sg(base) call. Demo videos attached below.

The software outputs .mp4 video files by leveraging python-opencv, numpy, and PIL (pillow). setup_sg() offers all of the following optional arguments:

setup_sg(input_np,output_file='screencap_vid',buff_hw=[720,400],use_clock=False,RAM_mode=True,max_screens=5000,cust_fr=60,use_native=False,write_threads=1,capture_key='p')

Short list of functionality:

  • Choose between a custom texture buffer being fed directly by the base.render default camera, or storing the entire window texture aspect2d and all (use_native=False for the texture buffer only) .
  • Choose between RAM_mode and “write to disk” mode, depending on your needs.
  • Provide custom resolutions via buff_hw=[w,h] which elegantly apply to either the texture buffer, the cv2 resize + interpolation, or both at once, depending on your mode settings.
  • Automatically provides you with regular progress updates via the console, as shown below:

Instant replay recording initiated.
Working…
pandarecord RAM_mode=False use_native=True Threaded write on: 10 threads.
Finished writing images.
Beginning video conversion.
The current average framerate: 434.7
Video conversion complete.
Saving video to program dir (last update).

Demo Video 1:

Demo Video 2:

Notes:

  • There are some cool async screenshot updates coming to panda3d soon. Once those are more official I intend to update panda3d-screenrecorder to leverage the benefits.
  • Currently use_native=True (the entire 2D/3D window capture) will default to threaded write to the disk, even if RAM_mode=True . You may only use RAM_mode with use_native=False currently. I plan on fixing this later on.
  • Warning: This is fairly powerful software. You can and will fill your RAM and even your hard drive entirely if you ask it to store a million 1440p screens in RAM or on the hard drive.
  • I’ll try to answer any technical questions that might come up which I am sufficiently familiar with to answer.
3 Likes