images | audio | feed | contact

pullingshots

Record My Window -- a screencasting script

I don't do screencasts a lot, so it never fails that when I want to record a screencast, I have to re-learn how to accomplish it or go searching for a good app. My requirements are always pretty simple... choose my window, then record and output a high-quality video file. A while back I wrote a simple little script that pulls together a few utilities (xwininfo, recordmydesktop, and ffmpeg), and my problem is solved! Now I just have to remember that I have a script. :)

#!/usr/bin/env perl

use Modern::Perl;

## Get window geometry and position from xwininfo
my $wininfo = `xwininfo`;
$wininfo =~ /-geometry (\d+)x(\d+)(\+|\-)(\d+)(\+|\-)(\d+)/;
my $width = $1;
my $height = $2;
$wininfo =~ /Absolute upper-left X:\s+(\d+)/;
my $x = $1;
$wininfo =~ /Absolute upper-left Y:\s+(\d+)/;
my $y = $1;

## Run recordmydesktop
system "recordmydesktop -x $x -y $y --width $width --height $height -o $ENV{HOME}/Desktop/screencast";
## Convert to mp4
system "ffmpeg -sameq -i $ENV{HOME}/Desktop/screencast.ogv $ENV{HOME}/Desktop/screencast.mp4";

Note that ctrl-alt-s will stop the recording. (ctrl-alt-p will pause/resume it)

posted at 2011-06-10T06:05:52 by baerg