A little post about using apitrace to capture gameplay sequence, the idea stem from this post http://kivy.org/planet/2011/06/recording-opengl-output-to-h264-video/
Why using apitrace rather than FRAPS or other video capture software?
My goal was to have a free way of capturing 60 fps gameplay sequence in good quality without the need of an extra fast computer.
My biggest grip with FRAPS is the lack of color fidelity by default (you have an option in FRAPS to change that, but it stress even more your computer, making it extra hard to capture 60 fps sequence) and the compression algorithm which tend to decrease dramatically the quality of the end result. Having a game where graphics consist of 1 pixels borders, with lots of distinctive colors, my test with FRAPS and PlayClaw didn’t go well, and I ended up looking for a solution to output gameplay sequence directly to png files.
What is apitrace
Quoting the official site :
apitrace consists of a set of tools to:
- trace OpenGL, OpenGL ES, Direct3D, and DirectDraw APIs calls to a file
- replay the recorded calls from a file, on any machine and, for OpenGL and OpenGL ES, on any operating system
In short, you first create a trace file, then replay it to generate png images for each frames that you can stitch together in a software like Virtual dub
How to capture gameplay sequence
First download apitrace from the official website, http://apitrace.github.io/ in the bin folder , you will find various programs, apitrace an glretrace are the only one we will use.
Capture gameplay sequence:
apitrace trace [path to exe]
It generate a trace file in the current directory with the same name than the exe
Generate a sequence of png file:
glretrace -sr [path to trace file] --call-nos=false --snapshot-format=RGB
this generate a png file for each frame, and put it on sequential order (with the –call-nos=false option , by default, it use a generated number, thing that we don’t want to use)
Create the final gameplay video
Load the first png file of the sequence with virtual dub, since the files are in sequence, virtual dub will automatically import the whole sequence. You can also select an image in the middle of the sequence, virtual dub will load only the file numbered after the
Don’t forget to change your source framerate, go to video > framerate and set the framerate to 60 in source rate.
If you want to generate a gif file, use Frame rate conversion, and set the value to 30 in convert fps. or use “Process every other frame (decimate by 2)” option. (the result is roughly the same, but depending of the sequence the smoothness of the exported gif could differ)
If you want to keep only a part of the image, use the null transform filter to crop the result (especially useful to reduce the size of gif)
Export to avi, and you have your video, in all it 60 fps glory! With the default parameters, you will still have a sub par result, next time, I will look into generating a HD video out of our gameplay sequence.