Monday, August 03, 2009

Briefly: recordmydesktop

Occasionally I have needed to make screencasts for my students so that they would have something to look at in their own time. There are two tools that make this easy on Linux (both should available in the yum or apt repositories):

Recordmydesktop does as it sounds: it records the desktop. It has options to set the size of the area to record as well as the window you would like to record. I like to choose the window option myself. I also like to record without sound, but you can figure out how to modify the script to remove that option if you so choose.

FFmpeg is a nice tool that allows you to convert, record and stream audio and video. I use it to convert the resulting video from recormydesktop to flv format in order to upload to photobucket or elsewhere.

To make my life easier, I have created the following script that takes in 1-2 arguments. The first argument should be the desired name of the resulting video file. The second argument is an (optional) amount of time to wait before recording. The default wait time is 3 seconds.

When you run the script it waits for you to click on the window that you wish to record by using xwininfo to get the window id number. You will notice that the mouse changes to a + sign as it is waiting for you to click. Once you click the window, it will begin recording that window area after the appropriate wait time has transpired. The video is converted to [chosen filename].flv after you have stopped recording (CTRL+C in terminal from which you started the script).

Feel free to do with as you please. The script can be found below:


#!/bin/bash
#
# Warning: this does not have robust error checking!

bad=67
if [ $# -lt 1 ]
then
echo "Usage: $0 [filename] [[optional time]]"
exit $bad
fi

if [ $# -eq 1 ] #check for arguments
then
time=3 #if one (only filename) exists, sleep for 3 seconds
filename=$1 #set filename
else
time=$2 #else, we'll sleep for $2 seconds
filename=$1 #set filename
fi

recordmydesktop -windowid `xwininfo |grep "Window id:"|sed -e "s/xwininfo\:\ Window id:\ //;s/\ .*//"` -o $filename.ogv -delay $time --no-sound

ffmpeg -i $filename.ogv -b 384000 -s 640x480 -pass 1 -passlogfile log-file $filename.flv

6 comments:

Anonymous said...

Hi Jamie,

nothing is boring. For me not. I found a script, I can use it :D

Thank you,
ali

Jamie Levy said...

Thanks cool!

Glad something was helpful ;-)

Chris said...

Hi Jamie,

glad I found your script as selecting a window to be recorded via GUI won't work for me somehow.



I have recordMyDesktop v0.3.8.1 installed.


Running your Script lead to this error:

############################
Error when parsing `-windowid': libpopt error: -11
############################

man-page reads:
--windowid id_of_window
id of window to be recorded.




Apparently you are missing a second "-" for the windowid-Option.


regards, Chris

Chris said...

same for option delay:

Must be --delay instead of -delay

Jamie Levy said...

They have probably changed the options since this script was written. It worked fine "as is" when I used it. Thanks for the notice.

Anonymous said...

Nice script - worked for me when I added a hyphen as commented by Chris