DrPetter's homepage


Desktop video capture with proprietary "almost lossless" video compression to enable realtime disk storage with reasonable filesize. The compression is lossless in almost all scenarios, but in some very rare cases it would fail to detect differences between adjacent scanlines or frames, and a few incorrect pixels would slip through.

This was actually one of the most enjoyable projects I've ever worked on. I started out by writing some mundane code to grab the desktop framebuffer, just to see how fast it would be. Surprised at seeing rates of around 50 fps, I was intrigued and ready to try making something that could actually record video. Saving uncompressed frames out to disk was quickly deemed impractical, so I had to come up with a quick and efficient compression scheme. During a couple of days I sat at lectures and scribbled down various ideas in my notepad while rudely ignoring the lecturer.

What I ended up with was a kind of RLE compression that coded differences between adjacent scanlines and frames. Doing per-pixel comparisons was too slow, so I used blocks of 16 pixels hashed into single 32-bit words. If a block hash was identical to the one on the scanline above, those pixels would be reused. Same if a hash was identical to the corresponding one on the previous video frame.

As a result, I was able to record video at full 1680x1050 resolution and 30 fps and 32-bit color, with the resulting files being very small. Several minutes of capture would only consume 10-20 MB if the content was normal "flat windows" and no moving high-color images. Scrolling a photo-heavy website or watching a video clip was pretty much the worst case, since most of the pixel data changed every frame. Walkthroughs of typical applications worked great though, where you're mostly causing small changes to a static screen. Even painting and scrolling the canvas in CherryBrush wasn't too bad.

I added some post-processing to automatically crop out a rectangular 640x480 region that smoothly follows your mouse cursor, which is helpful for tutorial videos. It also has a keyboard overlay that shows keys being pressed.

Here are some youtube videos I made using this application:

musagi demo video

CherryBrush fill demo

CherryBrush animation demo

...and a funny screenshot showing early broken compression and a suitable quote:

Unfortunately I didn't quite take it far enough in terms of usability that I can upload a public version. The main thing it lacks is trouble-free conversion from the native video format into something standard like AVI. Currently, that process involves saving out a zillion PNG images and running the conversion in virtualdub. There are also a few other kinks that make it quite non-obvious to use.

Might remedy this some day.

Back to all projects

Page updated on March 25   2010