Record Video Script

Record Video Script. For your smooth video capture needs.

  1. Add Logic Sensor, choose puls mode, 1 for 60FPS, 2 for 30FPS

  2. Add Game Property “counter”, 0.

  3. Add Python Controller, choose the script. (Create also a text block and paste the code)

The frames will be saved in PNG in the same directory as your blend file.

from bge import render,logic

cont = logic.getCurrentController()
obj = cont.owner

sep = ""
try: num = str(obj['counter'])
except : obj['counter'] = 0; num = str(obj['counter'])

filename = sep.join(["//",num,".PNG"])
obj['counter'] += 1

For a Game Logic setup, with activation and deactivation with a keypress. Please see @Mobioussetup (do not forget about the “counter” game property):


You sir are a GOD!

sad we cant save jpgs with this, because of a bug

Wait, does this work? I tried it just now, and I think one problem is that the script lowers FPS so that it only captures every 10th frame or so…

EDIT: It does work, just put the script in the Game Logic of the camera.

Update of the script:

from bge import render,logic

cont = logic.getCurrentController()
obj = cont.owner

if not 'counter' in obj:
    obj['counter'] = 0

if not 'filename' in obj:
    obj['filename'] = "frame"

if not 'filepath' in obj:
    obj['filepath'] = "//render/"

num = str(obj['counter'])
num = num.rjust(4,"0")
filepath = obj['filepath'] + obj['filename'] + num + ".PNG"

print ("saved " + filepath)

obj['counter'] += 1

EDIT: It does not work for Standalone Player it seems… im looking for the error, EDIT2: Remove the fileextension “.PNG” for it to work in the standalone player.

Ohhh… what a letdown.

This is the result using makeScreenshot when you are using videotextures in shaders in the Standalone: