Replay video generation

Started by
2 comments, last by purina 4 years ago

Hello, we are currently using mp4 and ffmpeg to generate replays, but there is one big downside - if the game crashes, the replay is corrupted. Do you know video format, which allows runtime generation of the video and if for some reason the game crashed, we still have working replay, which we can show? Generating the replay after the game has finished is not an option, because the player will have to wait a couple of seconds. Also we need the video to be compressed.

Based on my tests with ffmpeg, mkv is such option, but there are cases, where the video is corrupted and it does not know when to finish.

What is the best approach in this scenario? Should we write our own video format/player? Is there video format, which is more suitable for this case?

Advertisement

Is it a must have to get a video or is a “replay"-function also a suiteable option?

I don't think Blizzard has real video generation in their games rather than snapshotting the game's event loop and doing a simple replay of the events. Maybe this is also something for you?

If you still need videos, crashing can be prevented if you record to the next keyframe. Compressed videos contain keyframes and transitions between them. To prevent coruption of the video, you could record to the next keyframe, save that to disk (maybe using memory mapped files to have a continous stream of video data) and record the next couple of frames until the game ends.

Please note that depending on your games resolution and graphics, even with compression such a video can increase in size very quick. It will likely be the most common source of game crashes when RAM or the disk is out of memory

A lot of games don't actually record video (although there is a long list of external programs that can do this with almost any game), but either player inputs (if fully deterministic update/logic) or otherwise some kind of state that will allow a deterministic replay.

As a player, one very nice thing I like with these system is the ability to move the camera and view other data in the replay, as well as just watching what was on that players screen. However often such replays will be lost/broken by any updates, so will need to be saved as a video after the game for long-term storage.

As for corruption, pretty sure software can playback an "incomplete" file (although things like duration etc. might be broken, you could "re-save" the file to fix it) if you are flushing to disk frequently. A number of frames before the crash are likely to be lost however. To keep everything in a crash situation, you would probably need to record via an external process.

This topic is closed to new replies.

Advertisement