Video capture

Started by
4 comments, last by ElectroDruid 15 years, 9 months ago
Hi, I need to implement a video capture feature into the game I'm working on, primarily for debugging purposes (so for example, if someone else can reproduce a bug that I can't, they can send me a video of it happening, along with any other log files created by the program). Here's kinda what I'm looking for: - Suggestions which will work cross-platform are preferable. I'm developing the game on Windows, but I'd like to be able to port (and test) the game on other operating systems, so Windows-centric code isn't likely to help much. I'm rendering with OpenGL, for what it's worth. - I'd much prefer a software solution, written into my game code than a solution which requires all kinds of video capture card setups and stuff. - Having the game save out as readymade video files (AVI, or whatever) would be preferable to spitting out individual numbered images to be stitched together into a video later, assuming that video files can be created on-the-fly whilst still maintaining playable framerates. - If I do have to spit out individual images, can anyone recommend a (ideally free) package for doing so relatively easily and flexibly? - Recording audio with the video would be nice, but is by no means essential. I dug around GameDev a bit, and found this: http://www.gamedev.net/reference/articles/article2063.asp but the code obviously never got finished. DirectX stuff and OpenGL stuff is kinda weirdly mashed together in the code example, it looks quite Windows-centric, and it crashes every time it tries to actually get a screen capture. I've not been able to find much else in the way of resources. Does anyone have any suggestions or advice?
"We two, the World and I, are stubborn fellows at loggerheads, and naturally whichever has the thinner skull will get it broken" - Richard Wagner
Advertisement
Video capture is quite processor intensive and I doubt you will be able to implement a decent real time video capture system that still provided high game frame rates.

I would recommend that you create a replay system for your game instead where you record the user input and the state of the game into a file so that the game can be played back later. A good example of this system is in the game StarCraft. Once the game finished you had the option of saving a replay and you coulld watch your entire game replay itself.

Then maybe if you really wanted to you could add to your replay player an option to export the replay to video (even though it would take a good while to do so). So in essence I recommend against trying to record the video live during the actual game because the performance hit would more than likely be quite noticeable.

I've written replay systems before, and given that this game will have network multiplayer, I might well write one for this game just as an additional debugging tool. Replay systems can be really useful, although in my experience they can involve a *lot* of maintenance to keep deterministic and make sure you always get the same playback from the same inputs. I thought in the meantime the ability to just hit a button and start splurging out video when something looks odd would be a more robust system, but if the encoding is going to cripple the framerate I might have to look at other approaches.
"We two, the World and I, are stubborn fellows at loggerheads, and naturally whichever has the thinner skull will get it broken" - Richard Wagner
Quote:Original post by ElectroDruid

- Suggestions which will work cross-platform are preferable. I'm developing the game on Windows, but I'd like to be able to port (and test) the game on other operating systems, so Windows-centric code isn't likely to help much. I'm rendering with OpenGL, for what it's worth.


I'm not aware of such solution. The process of video card buffer capture tends to involve some API specific hacks.

Quote:I dug around GameDev a bit, and found this: http://www.gamedev.net/reference/articles/article2063.asp but the code obviously never got finished. DirectX stuff and OpenGL stuff is kinda weirdly mashed together in the code example, it looks quite Windows-centric, and it crashes every time it tries to actually get a screen capture. I've not been able to find much else in the way of resources.


Yes, this is what this kind of solutions look like. This is why there's basically two applications that do that, Fraps and GameCam.
You could always render each frame to an FBO and then stream the target texture every frame to a file of whatever video format you feel comfortable coding for. It's platform independent, as long as you have a sufficently recent OpenGL implementation (I think FBO's were introduced in OpenGL 1.1). The rendering itself is straightforward to implement; how easy it is to stream it to a video file, I have no idea. Saving the frames as images is fairly trivial, since you have the image data easily accessible in the texture after each frame has been rendered.

Speed will be an issue, of course; besides having to render every frame twice, you'll do a lot of hard drive access. The usual tricks to reduce file size will of course work, such as compressing the frames, rendering to bw images, reducing resolution etc.
-------------Please rate this post if it was useful.
I took a look at Fraps after Antheus mentioned it. It seems to do everything I need it to do without me needing to write a single line of code :) It's Windows-only thing, but right now the fact that I've got something that works "off the shelf" has saved me enough time that I think I'll just try to find a Linux equivalent program as and when it turns out I need one.
"We two, the World and I, are stubborn fellows at loggerheads, and naturally whichever has the thinner skull will get it broken" - Richard Wagner

This topic is closed to new replies.

Advertisement