Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
In-game recorder for alien arena
04-13-2017, 03:21 PM,
Post: #1
In-game recorder for alien arena

It's been a long time since my play in alien arena, but I never forget about about the old times, so now I decide to come back with some interesting idea as in the topic.

Recently I have tried to implement a in-game recorder for supertuxkart, and it was a success. Than I tried a more ambitious plan which is to separate the code for it out of supertuxkart. The result is here:
This is a c++11 library with exposed API "extern C-ed" and bsd licensing, which allowing a very wide usage for everybody.

Currently it builds fine in my linux, for windows I think you will need at least msvc2013.
The prebuilt binaries are here (see windows folder), the dlls are built with static runtime
library, so I think it should work without msvc2015 runtime:
Just copy suitable dll / lib / include there.

Than I tried to hack alien arena next, first include openglrecorder.h in both files:
in r_main.c int R_Init( void *hinstance, void *hWnd ):
Quote: (around line 1708) R_GenerateShadowFBO();
Com_DPrintf("%s : %d\n", __FILE__, __LINE__ );

RecorderConfig cfg;
cfg.m_triple_buffering = 1;
cfg.m_record_audio = 1;
cfg.m_width = 1920;
cfg.m_height = 1080;
cfg.m_video_format = OGR_VF_VP8;
cfg.m_audio_format = OGR_AF_VORBIS;
cfg.m_audio_bitrate = 112000;
cfg.m_video_bitrate = 200000;
cfg.m_record_fps = 30;
cfg.m_record_jpg_quality = 90;
ogrRegPBOFunctions(qglGenBuffersARB, qglBindBufferARB, qglBufferDataARB,
qglDeleteBuffersARB, qglMapBufferARB, qglUnmapBufferARB);
You may adjust the settings above as name implies (see openglrecorder.h for details), use OGR_VF_MJPEG will allow abetter quality, though the video will be large.
The sounding record in linux is done by pulseaudio while windows is wasapi
Notice: In windows you may need a function to wrap againist qgl* function, as some of it may have a __stdcall supplied, this is true for glew in windows which supertuxkart uses.

You can check in my repo for details.

Then in cl_main.c:2679 near the end of "if ( render_trigger )" (I assume this is the last rendering command?) add this: (of course the static int is a quick hack!)
Quote:static int prepared = 0;
if (prepared == 0)
prepared = 1;

Finally in r_main.c R_Shutdown, add an ogrDestroy(); for clean up when exit.

Then alien arena will record its rendering context, which ogrCapture() will grab the current frame asynchronously if you enabled m_triple_buffering, until you exit the game. It's a c++11 library, so unique_ptr I used will auto-delete and join the recording threads. Finally a "record.mkv / .webm" will be formed in the current running directory.

In my testing audio / video sync is very good, also libopenglrecorder will auto duplicate / discard frame so as to fits your m_record_fps.

You can see how I did for supertuxkart with complete features / callbacks here:
Search for all the functions about "ogrXXX"

Interesting idea? Though I don't know how input / output handling is done in alienarena, so a user can press a button to start / stop record....

BTW a not-sure-if bug...
In glw_imp.c Sys_SetCpuCore Method, you seem to always SetProcessAffinityMask to 1 (sys_affinity->value is always 1), at least in my task manager crx.exe always uses only 1 core of all CPUs, is it intended? At least for vp8 live encoding I need to comment out those code to utilize all cores without affecting the gameplay.
04-13-2017, 03:26 PM,
Post: #2
RE: In-game recorder for alien arena
So, for a noob like me, reading this, you are saying that this can record the game
directly to a video output?
Instead of the need capturing it afterwards with e.g. Fraps?

Are there any requirements on the pc specs for this to work fluently?

What is the fps?
What quality output do you get? 1080?
Ban? Who Can I Ban???
04-13-2017, 11:07 PM, (This post was last modified: 04-14-2017, 04:27 AM by Benau.)
Post: #3
RE: In-game recorder for alien arena
Directly to a webm or mkv with sound, no more additional work

fps is the m_record_fps you specified, quality will be the best if you use OGR_VF_MJPEG which will be an mjpeg mkv + vorbis audio, which no encoding happening in the background, and this is suitable for slow pc. (vorbis encoding is low-cpu-usage so doesn't matter). if you specified cfg.m_width = 1920; cfg.m_height = 1080;, than the output video will be at 1920x1080 with 30fps.

For on-the-fly VP8 encoding, you need at least a dual-core CPU with ~3.0ghz, and you can adjust the video bitrate if you want higher VP8 quality (H264 not done yet)

I have tried the above hacks in Alien Arena, and I successfully recorded a video + audio file in both windows / linux after exiting Alien Arena.

Forum Jump:

Users browsing this thread: 1 Guest(s)