• Install screen capture recorder: https://github.com/rdp/screen-capture-recorder-to-video-windows-free
  • Put the ffmpeg directory that it installs on your path. On my machine that was: C:\Program Files (x86)\Screen Capturer Recorder\configuration_setup_utility\vendor\ffmpeg\bin
  • Run the following batch script:

The batch script:

echo off
:loop
ffmpeg -loglevel info -t 300 -f dshow -video_device_number 0 -i video="screen-capture-recorder" -vcodec libx264 -pix_fmt yuv420p -s hd720 -preset ultrafast -vsync vfr -acodec libmp3lame -f mpegts - | ffmpeg -f mpegts -i - -c copy "current.mp4"
del old.mp4
mv current.mp4 old.mp4
goto loop

Assuming you run some form of Windows and you don't actually need near real time recording then I think what you want is TimerSnapper.

http://www.timesnapper.com/

It takes screenshots of your desktop every few seconds and stores them. It's really intended for use to help developers keep track of what they worked on during the day. I believe it has a user configurable amount of time to keep the screenshots but I doubt it will go as low as 30 seconds. Better to have too much data than too little.

There's an older version that is free and there's a newer Professional version with a lot more features.


OK, On linux, the following script will create three .avi files in /tmp/ that will keep the last few instants recorded.

#!/bin/bash
while true; do
    ffmpeg -f x11grab -s 1280x800 -r 60 -i :0.0 -f avi /tmp/rolling.avi &> /dev/null &
    disown
    PID=$!
    sleep 30; 
    kill -KILL $PID
    cp /tmp/rolling_1.avi /tmp/rolling_2.avi
    cp /tmp/rolling.avi /tmp/rolling_1.avi
    rm /tmp/rolling.avi 
done

Obviously, you'll have to replace the args of ffmpeg for your screen res, etc...

A shout out to b0fh and ~quack for helping me with some bash notification problems in this thread.