How can I render GL Game to movie file or images?

I did read ahead and found this bit
But I do not know how to change it to create the files to a folder in the /tmp dir
It instead saves to the root of the drive.



import Rasterizer
cont = GameLogic.getCurrentController()
obj = cont.getOwner()
sep = ""
num = str(obj.counter)
filename = sep.join([num,".jpg"])
#Un-comemnt the following line will save a bitmap every frame to disk.  SLOW!
Rasterizer.makeScreenshot(filename)
obj.counter += 1

Yeh I never figured that out either. sometimes it saves them in the programmes folder and sometimes in the directory where your blend file is. I just move them after its done…

The other thing is it does not put leading zeros on the file numbers so the order is wong when you finish. I use Lupas Rename to rename them, its very good. Must learn python sometime

Hey guys … I fixed the syntax to do what you want, I can’t test it though

import Rasterizer
cont = GameLogic.getCurrentController()
obj = cont.getOwner()
sep = ""
num = str(obj.counter)
num = '%(#)03d'%{"#":num}  # puts leading Zeros =>prints as 001,002,010,100
filename = sep.join(["c:\\",num,".jpg"]) #added location (windows)
#Un-comemnt the following line will save a bitmap every frame to disk.  SLOW!
Rasterizer.makeScreenshot(filename)
obj.counter += 1

under windows you need two backslashes such as c:\program files\ …etc
you can simply /user/temp under linux.

To add more numbers switch 03d to 05d… etc
Let me know how it goes

Many thanks for looking into this Maxwildcat

found it would not write the file so had a look and found num was a string in the original script and needed to be an integer.

import Rasterizer
cont = GameLogic.getCurrentController()
obj = cont.getOwner()
sep = “”
num = obj.counter
num = ‘%(#)03d’%{"#":num} # puts leading Zeros =>prints as 001,002,010,100
filename = sep.join([“c:\Temp\Name”,num,".jpg"]) #added location (windows)
#where c:\Temp is the Location and ‘Name’ is the word appended to the front of the filename giving you Name001.jpg

#Un-comemnt the following line will save a bitmap every frame to disk. SLOW!
Rasterizer.makeScreenshot(filename)
obj.counter += 1

Thanks so much for doing this, I use the script a lot for making films and this will save me loads of time :slight_smile:

(would still like to know why sometimes it creates PNGs for some reason…)

It might create PNG’s because the render output is set to PNG, try switching that to JPG

humm I see, although obj.counter should be returning an int …

if your seeing an error like this on the formatting line
“TypeError: int argument required”

you can resolve by replacing the line with

x= '%(#)04d'%{"#":int(num)} # puts leading Zeros =>prints as 001,002,010,100

With the video texture player you will be able to record the game to a video file I think.

If they do that, I will be SO HAPPY!

Andrew-101 -

It might create PNG’s because the render output is set to PNG, try switching that to JPG

I realised now it was after I packed an image as a PNG in the UV/Image editor… something to look out for