Making Screen-Capture Moviesby Robert Bernier
Lights, Camera -- ACTION!
If a picture is worth a thousand words, then how about a thousand pictures -- or a graphical animation? Getting the message across depends a lot on the tools at hand. It's one thing to stand in front of a classroom with a blackboard, a projector, and a room full of PCs, but it's quite another thing describing a set of ideas to multiple people who are standing in front of a kiosk, in a hall filled with competing noises and distractions. Wouldn't it be great to create animated screen shots without first taking a course in multimedia and purchasing expensive development applications? Of course it would!
The Screen-Shot Movie
Let's set the stage: our objective is to create a screen-shot movie that demonstrates how to use a certain feature in an application. In addition, we should be able to provide commentary within the movie to give background as to what's going on.
Ideally, we can make a movie with tools that don't take long to learn and use. The technique demonstrated in this article shows how to capture screen shots in rapid succession. These screen shots are then converted into a single file that can be read by nothing more complicated than a browser.
We need the following tools:
- The ImageMagick command-line utilities, to create, edit, and convert images from one format to another.
xwininfo, the window information utility for X.
- A small
bashscript to record multiple screen captures.
How to Use the Tools
Launch the application you want to record. Use
obtain the target window's hexadecimal ID number. In this example, the ID
0x140001d, comes from the fifth line in the output
bernier@wolf:~/tmp/animate$ xwininfo xwininfo: Please select the window about which you would like information by clicking the mouse in that window. xwininfo: Window id: 0x140001d "making movies.sxw - OpenOffice.org 1.1.0 " Absolute upper-left X: 4 Absolute upper-left Y: 18 Relative upper-left X: 0 Relative upper-left Y: 0 Width: 920 Height: 630 Depth: 16 Visual Class: TrueColor Border width: 0 Class: InputOutput Colormap: 0x1400001 (installed) Bit Gravity State: ForgetGravity Window Gravity State: StaticGravity Backing Store State: NotUseful Save Under State: no Map State: IsViewable Override Redirect State: no Corners: +4+18 -100+18 -100-120 +4-120 -geometry 920x630+4+18 bernier@wolf:~/tmp/animate
import command to capture the window. If this succeeds,
you'll hear two beeps from the PC's speaker. If you want a frame around the
screen capture, add the
-frame switch. By the way, the
command can capture screens to any file format, but the MIFF format is very
import -window 0x140001d openoffice.miff
View the screen capture with
If you prefer a different format, use
convert to, well, convert
convert openoffice.miff openoffice.png
With all of those steps explained, here's a simple
bash script to collect the screen captures for our movie. It takes two command-line arguments: the window ID and
the amount of shots to capture:
>#!/bin/sh # A simple bash script to screen capture # # Supply two arguments, the window id and number of captures let x=1 # loop until it has captured the number of captures requested while [ "$x" -le "$2" ] do import -window $1 "capture$x.miff" # uncomment the line below # if you want more time in between screen captures # sleep 2s let x+=1 done
Invoking the script is straightforward. Make it executable, then type:
./capture.sh w_id no_capt
w_id is the hexadecimal ID obtained from
no_capt is the number of screen shots to
animate to animate the captured images:
animate -delay 20 *.miff
delay number controls how much time to wait between the
individual screen captures. The units are in hundredths of a second.
Finally, converting the animated images to a more
convenient, single-file format is accomplished by using the
There are several likely formats:
MNG is a license free, multi-image file format, similar to PNG but with more bells and whistles. This format is not yet widely used, but it is very neat and there are plug-ins for all the major browsers.
convert -delay 20 *.miff capture.mng
GIF, you should know.
convert -delay 20 *.miff capture.gif
MPEG encoding requires you to download and compile the
mpeg2encodeutility source code, but it does allow you to add sound.
convert -delay 20 *.miff capture.mpg
Enhancing a Screen Capture
It's not always enough to replicate a series of keystrokes and pop-up
menus. Sometimes, you need details that help explain what's going on better.
For that matter, it's nice to make a plain screen look fantastic with all sorts
of graphical, special effects. That's where
mogrify comes in.
mogrify -fill blue -pointsize 25 -draw 'text 10,20 "Hello World" ' capture1.miff
The above command adds the phrase "Hello World" to the
capture1.miff image. The words will be colored blue, with a
point size of 25. The words are placed relative to the top left corner of the
image in terms of
x (10 pixels to the right) and
y (20 pixels down)
montage command makes the additions on a copy of the
original. Remember to use the
-geometry switch with the current
window size (for example,
-geometry 920x630); otherwise, the copy
will have a size of 120 by 120 pixels.
montage -fill black -pointsize 50 \ -draw 'text 100,300 "Robert Bernier" ' \ -geometry 920x630 capture1.miff capture1a.miff
Drawing a box behind the words will make them stand out:
montage -fill yellow \ -draw 'Rectangle 80,250 400,400' \ -fill black -pointsize 20 \ -draw 'text 100,300 "@instruction1.txt"' \ -geometry 920x630 capture1.miff capture1a.miff
Remember that you read the switches from left to right. Why? Because each set of options can be changed by the next option to its right. You won't be able to see the words in this next example because the yellow box covers them, as drawing text occurs before drawing the colored box:
montage -fill black -pointsize 20 \ -draw 'text 100,300 "@instruction1.txt"' \ -fill yellow -draw 'Rectangle 80,250 400,400' \ -geometry 920x630 capture1.miff capture1a.miff
By the way, did you notice the
@ token instructs the utility to place the contents of a text
file, instruction1.txt in this case, into the image.
Screen Capture Tips
The best way to figure out what looks good is by experimentation. Here are a few things I've learned that may save you some time.
The more instructions and options on the
importcommand, the longer the capture will take.
Do the screen captures using the MIFF file format. Capturing to any other format can slow down the capture process.
The screen-shot capture rate depends on the window size.
Listen to the beeps; this will give you an idea how quickly or slowly you should navigate through your window.
rootflag to capture the entire screen of your desktop:
import -window root capture.miff
Identify and rehearse the steps that you want to record. This is known as a making a storyboard. The screen-capturing process will save every action, good and bad, so practice the steps before invoking the
sleepcommand inside of the
bashscript can give you much-needed time to prepare the application for the next screen shot without feeling rushed.
Reviewing each shot after capture helps identify the good and bad images. Simplify this tedious operation by using
displayto load and edit an entire series of images with one command.
You may have noticed that listing files with numbers doesn't always sort the way you want. Here's a shell trick to ensure that the files are never out of sequence:
display capture?.miff capture??.miff
Clicking once on a displayed image will put the ImageMagick program into editing mode, and clicking the image again will make the menu disappear. The editing tools have many of the same options that are available on the command line. Pressing the space bar advances to the next image.
Improve the flow of your presentation by adjusting the speed and duration of the frame rates of your animation. You can do this while converting the individual images.
Add comments and special effects to the images only after you've established their respective animation frame rates. Make a backup of your animation first.
About the Demo
Either download the demo or run it directly from your browser using
animate. You can also convert it into another file format to
better suit your hardware. Be patient. MNG files must be first uncompressed
and then cycled once before they will behave properly; this can take up to a
minute. However, if you convert it to a GIF, the file will larger, but it will respond
instantly in the browser. Converting the file to an MPEG permits play with any
multimedia application, such as
mplayer, without any startup time
Developing the small screen-capture movie demo for this article made it painfully obvious to me that you should exercise discretion when choosing your file format. I experimented with GIFs, MPGs, and MNGs. For example, the resulting uncompressed GIF was 14MB. (ImageMagick binaries do not use the proprietary compression algorithm unless you enable that option and recompile.) The MPG was 4.6MB. The MNG was the smallest at 500K. The fancy screen-capture demo was substantially larger, with the GIF at 26MB, the MPG at 6.7MB, and the MNG again the smallest at 4.7MB. However it was interesting to note that converting the fancy movie MNG to PCX files and then converting it back reduced the size to 1.6MB, 65% smaller.
The MNG format is clearly superior to GIF, but it is not very well
supported, and takes quite a long time to decompress before it's ready to play.
Mozilla's MNG plug-in failed to bring up the small demo. The ImageMagick
animate worked fine. KDE's Konqueror could only run the
small demo, where an HTML tag embedded the MNG file with the
The GIF version of the demos played well in
Another factor to consider is that files such as GIF and MNG don't really
"stream," so players need to load the entire file into RAM before you can see
it. Large graphics may consume too much RAM, crashing your application. One
easy solution is to enlarge the virtual memory by using a swap file. This issue
may also come up when using
MPG is a good choice when resources are at a premium and it's not possible
to add a swap file. You may need to experiment with the
to prevent color loss, though.
animate is good because the presentation is so exact and easy
to control. Viewing GIF format guarantees that any browser can read it fast. Beware,
though -- both of these formats are RAM hungry.
ImageMagick is a very sophisticated graphics manipulation package. This article has covered only its barest capabilities. Anybody who decides to use it as a development platform can increase his or her productivity by using scripts. ImageMagick has an API with a complete set of language bindings for over 16 languages, including Perl, Java, C, C++, and Cold Fusion.
For those who follow the articles of a certain FreeBSD girl, you can also do some very interesting things such as Hide Secrets with Steganography inside of your movie.
Several Linux multimedia development applications are available. Many of them have taken inspiration from ImageMagick.
Robert Bernier is the PostgreSQL business intelligence analyst for SRA America, a subsidiary of Software Research America (SRA).
Return to the LinuxDevCenter.com.
ffmpeg can also grab the screen
2007-08-11 20:54:00 AndresVia [View]
2006-07-05 03:13:41 beligum [View]
- Trackback from http://weblog.techopedia.net/archives/000291.html
Capture کردن صفحه نمایش در لینوکس
2004-03-09 00:13:22 [View]
2004-03-08 09:40:34 mmnmm [View]
2004-03-08 02:26:09 bazzargh [View]
VNC + ...
2004-03-11 01:26:52 oak [View]