How to increase Fraps performance with a ramdisk

I recently started playing Battlefield 3 and remembered that I have a Fraps license so I installed it and started recording some stuff. Unsurprisingly the performance made a big dip when I recorded. A glance at my PC told me the harddrive was at fault, probably bringing the whole system down due to IO.

Since my PC has more than enough RAM I decided to set up a 5Gb Ramdisk to see if that helped. It did, when writing the video files to the ramdisk I hardly had any performance hit. Unfortunately 5GB isn’t going to last long while recording 1920×1080 @ 40FPS (a few minutes footage at most).

Here is my little cmd file to create a 5GB ramdisk as drive J: and format it for usage:

Select All winbatch
1
2
3
imdisk -d -m J:
imdisk -a -t vm -s 5G -o rw -m J:
format J: /A:64k /V:Ramdisk /FS:NTFS /Q

So my next thought was to see if I could write a script to move files off the ramdisk when they were done being written to by Fraps. This obviously was going to cause IO load … the reason we were having performance issues in the first place, so I was skeptical about if this was going to help any. Especially since I also had to move the files away quick enough so that the drive wouldn’t fill up completely with the next file Fraps was writing. I wrote a little powershell script for this (yeah, a *nix Sysadmin writing scripts in powershell …)

Here is my little powershell script to copy the finished files from my ramdisk to a normal HDD (please excuse  possible ugliness, I’m a powershell noob):

Select All powershell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$source = "j:\*.avi"
$target_dir = "f:\fraps\movies\"
 
while ($true) {
    $files = gci $source
    foreach ($file in $files){ 
        $srcfile = echo $file.fullname
        $dstfile = echo $file.basename
        if ($srcfile) {
            try {
                move-item "$srcfile" "$target_dir$dstfile.avi" -ea stop
                "$srcfile Moved"
            }
            catch {
                "$srcfile in use, cannot be copied right now"
            }
        }
    }
    sleep 5
}

The last little problem I noticed is that the 5GB ramdrive wasn’t big enough (Fraps seems to create some dummy files and fills them up). Forcing Fraps to make smaller files by toggeling the recording fixed that though -> pressing F9 twice fast will drop a few frames though. I used my Logitech G13 for that, just had a key mapped to press F9 quickly every 60 seconds. The shortest gap I could get working reliably is 50ms.

This all probably sounds awfully complicated, but it works and solves my problem. Fraps is great software, but it would be immensly helpful if you could set the file size in the settings (instead of it defaulting to 4GB). Or, even better, if Fraps could rework their IO system to work more efficiently.

So to sum everything up:
- create ramdrive
- start script that copies files from the ramdrive to a normal HDD
- set fraps to store videos on the ramdrive
- start game, press F9 to start recording and then press the G13 key to toggle the F9 periodically


Trackback URL

  1. markval
    10/12/2011 at 11:00 pm Permalink

    Hi,
    You should try Bandicam.
    Compressed video is alwayz better.
    Look for Xvid on the fly or Avid Adrenaline then deflate to other formats.
    Cheers!

  2. kotysoft
    08/02/2012 at 2:13 pm Permalink

    Hi. I’m have same issues with fraps, and as I see, we trying record with same game :)

    I already tried RAMDISK for fraps before i read your post, and yes, it’s working flawless. But on my SATA2 HDD …. crap.

    my HDD has 95MB/s sequence write speed, but it looks it’s not enought for fraps. But final video files has less bitrate, so I don’t undestand… Somthing badly programmed I think.

    I’m trying to record on 1600×900@60fps.

    You have a good idea, and it’s a very good information/script, but currently I’m looking for an alternative disk cache with unique parameters, like uTorrent has for caching chunks.

    Alternatively I’ll try Bandicam (today), as prev. poster said. I hope it will works well.