Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm looking for a video encoding library in C++ that I can use to record game footage.

It can not be an external application like Fraps, it must be a library.

Ideally the encoding can be done in real time without affecting game performance too much, although this is not a must have requirement.

Another preference is that the video file being saved from the game is already compressed and ready to be used by most video players without any further processing. I realize that this might not be possible especially for real time encoding, so I would accept a trade off of having to process the file later for better compression and/or better file format.

I'd like to hear about your experience integrating the library into a game if possible and any interesting trade offs you had to make.

Some libraries support more that one file format or codec, so advice on the file format would also be appreciated.

share|improve this question
add comment

1 Answer

It depends on the use-case.

For recording games, I've seen that a general 'game record' mode where the game records the user input on a timeline so as to be able to recreate the game at any point to be really useful, and you can generate the video afterwards, or pass around these recorded games and others can watch using the game engine rather than a video player.

Or maybe you mean in-game capture that immediately converts to a video live and stores only the video. Assuming so:

The classic library is ffmpeg's libavcodec. You can compile this so it as to avoid GPL codecs and such.

Codecs like H.264 (libx264) are GPL - if that's ok with you, then fast presets and baseline profiles will work better than most. H.263 or even MJPEG otherwise.

But I normally stream y4m (its trivial to generate this format yourself without using the GPL lib) to an ffmpeg exe using my popen3. Why don't you want an external exe? Its a tidy way of allowing it to run on separate cores and coping with the fact that it may take longer to compress your video than it the game time it represents.

I have also concatentated to MJPEG using libjpeg internally and post-converted with FFMPEG.

And finally I have made live FLV streams so games could be watched live. This is surprisingly easy.

share|improve this answer
Will, is there any specification I can find online for y4m? I found this: wiki.multimedia.cx/index.php?title=YUV4MPEG2 But I'm not sure it's that reliable as I got a playable example of y4m and the header looks a bit different. thx –  user28945 Mar 28 '13 at 19:04
@Denis wiki.multimedia.cx/index.php?title=YUV4MPEG2 –  Will Apr 10 '13 at 5:51
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.