A few months ago, I wrote a post on how to do a picture-in-picture timelapse recording when dealing with a dual monitor setup where each monitor has its own separate X display.
Long story short, after a harddrive failure forcing me to reconfigure my linux setup, I went away from the dual X screen setup, to a single X display spanning the two montiors.
This means that a screen dump using
Putting together the various pieces mentioned so far, this is the final script.
If the above script for some reason skips a frame, this will cause problems when creating a video from them. A quick fix is to create a symlink to the previous file, for any missing frame.
While I wrote this post, I had the screen recording script running, and this is the produced video: