Saturday, December 1, 2012

Realm Video Recorder

If you have a 5-year old computer with integrated video card - you'll run all flash games without problems. But recording videos will be a problem.

I tried Fraps, Bandicam, Camstudio, Debut, Expression Encoder and some other recorders. None of them is perfect. The lag increases noticably and it makes the gameplay much worse. Fraps performs best among them but it's not free and it records the whole screen.

Reducing video size by half (to 400x300) and framerate to 15 fps helps to get better performance but the quality of video is very bad and the lag is still there anyway.

The main problem is that computer's processor is used to encode the video in real time. And encoding is expensive. What if the raw screenshots are saved during gameplay and encoded later?

That's why I think about writing my own recording software. It seems easy to achieve. Just capture the game rectangle 24 or 30 times per second and save them as raw BMP files. No processing, no compression. Those screenshots can be imported later into some encoding software to make a movie.

How much space is required?
one frame = 800 x 600 x 3 RGB components = 1 440 000 bytes
one second at 30 fps = 41.2 MB
1 minute = 2.41 GB
10 minutes = 24.1 GB
30 minutes = 72.4 GB
one hour = 144.8 GB
Those amounts seem affordable.
The FPS could be reduced to 24 or 15 to reduce disk usage.

The recorder dedicated to RotMG could take advantage of knowledge of game's interface. The 200 x 600 part on the left side rarely changes. Sometimes the HP/MP change, sometimes the item gets dragged in or out but most of the time it doesn't change. Saving only the differences between frames there practically eliminates that area. The frames would be reconstructed after recording is done. That leaves us with 600 x 600 main gaming area.

Let's calculate again for 600 x 600 and 24 fps.
1 second = 24.7 MB
1 minute = 1.45 GB
10 minutes = 14.5 GB
30 minutes = 43.4 GB
one hour = 86.9 GB

Now the disk should be good enough to cope with writes. How good should it be? I'll just copy some large file from one physical disk to another and see how long it takes...
Copying 4.2 GB file took 108 seconds.
That's 2.33 GB per minute. While only about 1.5 GB is needed.
So yes, my disk should perform well enough.

Things that should additionally improve performance:
    - saving to physical disk other than system disk
    - disabling compression and encryption for that disk
    - disabling antivirus software, at least for that disk
    - defragmenting the disk before recording
   
Some cheap compression schemes like run-length encoding, or looking for differences between frames, could be used to reduce disk usage. But they probably won't work well when they are needed most: during the intensive action sequences, when the screen is rotated. They would work well during loading screens or when the character stays still.

Another idea would be to monitor processor and disk usage and encode the movie in the background when the system is idle. The encoding progresses at its own slower pace, without interfering with game or with recording of raw frames.

Capturing audio that is in sync with video would be another question.

A completely different approach would be to record only user's input and network packets and use a modified game client to render the video later, perhaps at slower pace. This would be very cheap to record but things would probably get out of sync when replaying.

Another idea is to record the state of flash objects visible in the frame (tiles, their rotation, monsters, projectiles, text, etc.) and render the frames later. This would require a detailed knowledge of the game client.

I'm not going to write such software right now. Probably because the cheaper solution is to buy a better computer dedicated to gaming. I just wanted to get this idea out of my mind.

1 comment:

  1. Random comment, that seems to be a good idea, and it's easy to do?

    ReplyDelete