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

closed as off-topic by Krom Stern, Josh Petrie Dec 1 at 15:24

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about "how to get started," "what to learn next," or "which technology to use" are discussion-oriented questions which involve answers that are either based on opinion, or which are all equally valid. Those kinds of questions are outside the scope of this site. Visit our help center for more information." – Krom Stern, Josh Petrie
If this question can be reworded to fit the rules in the help center, please edit the question.

    
Questions on what library to use are off-topic on GDSE, I hear, as the responses will be overly broad, mostly subject to opinions, and peppered with thinly veiled advertisements. You may be able to rephrase your question to avoid this problem. –  Lars Viklund Dec 1 at 12:33

1 Answer 1

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

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