Screencasts

Creating screencasts (screencapture)

Several methods for creating screencasts in (K)Ubuntu Linux exist.

FFMPEG with x11grab

Recent versions of FFMPEG include x11grab, a module for screen capture. This method gives the best results for screencaptures and is one of the the most flexible methods, allowing a variety of audio inputs and audiovisual output formats.

The order of the options is important (since some options override others). -f alsa indicates the alsa audio input (an alternative is oss). -ac 2 indicates 2 channel recording (use -ac 1 for mono). -ab 192k means 192 kb/sec audio, which may be too high for your needs. (128k is average). -i pulse indicates to use Pulse Audio (assuming you have it set up) for audio input. -i :0.0 means to capture screen 0.0 (the primary screen). -acodec pcm_s16le means to save with lossless 16-bit audio encoding (which gives a large file). You can use another audio format (such as libmp3lame) here if you wish, or re-encode later when you do processing/convert to your final desired format. Also see the FFMPEG x11grab documentation for other options.

You can also capture to a video codec other than libx264 (although without the corresponding quality of H.264/X264). In a command terminal, type ffmpeg -formats E to see which video codecs your version of FFMPEG supports. For example, to create an .avi file with an XVID video codec and an Mp3 audio codec, use the command:

A benefit of using Pulse Audio is that several inputs can be combined, allowing both microphone input and music input, for example. The relative volumes can be controlled using Pulse Audio Volume Control (sudo apt-get install pavucontrol).

If you do not have Pulse Audio installed, you can capture from the primary audio input card by replacing

-i pulse

with

-i hw:0,0

or

-i /dev/dsp

It is possible to record only part of the screen by specifying an offset from the upper left corner of the screen. Use the option :0.0+10,20 where 10 is an example of a x-offset from the left of the screen and 20 is an example of the Y offset from the top of the screen. Also specify the size of the area to recorded, for example -s 320x240. A complete command might then be

After completing the screencapture, you can then edit and convert it to the desired final format, using FFMPEG (perhaps with the WinFF GUI), mencoder (with or without a front-end such as Avidemux), or a standalone video editor. Some examples of conversion methods are here.

kX11grab

kX11grab is the KDE version of QtX11grab, a frontend for FFMPEG/x11grab screengrabs. It is in alpha stage and does not yet work well.

Install kx11grab:

sudo apt-get install kx11grab

Start kX11grab:

K menu -> Utilities -> kx11grab

Install the newest version of FFMPEG with x11grab

Older repository-supplied versions of FFMPEG did not have X11grab nor X264 support in them. If you have a very old installation, you can install the newest version of FFMPEG and X264 using the instructions from this thread.

Note: The current, updated versions of FFMPEG in Lucid, Maverick, and Natty are all compiled with x11grab and X264 capabilities. On my Lucid machine, X264 version 85 is already installed, and on Natty, version 106 is already installed. The newest version of X264 (as of 8-2011) is version 116.

If you want the most current version of FFMPEG and the H.264 / X264 video codec, however, then compile and install new versions using these instructions (recreated here).

Uninstall x264, libx264-dev, and ffmpeg:

sudo apt-get remove ffmpeg x264 libx264-dev

Install dependencies needed for retrieving, compiling, and running the new versions (you may need to ensure the Universe and Multiverse repositories are enabled):

Note: Git uses port 9418 by default. Make sure the Git port is unblocked in your firewall. The last command will build a .deb package named something similar to /home/user/x264/x264_0.116.2074+git2641b9e-1_i386.deb. The installed package can be removed later, if desired, using dpkg -r x264.

Retrieve, compile, and install a recent version of FFMPEG. (Note: Ubuntu normally installs FFMPEG in /usr/bin/ffmpeg and related modules in /usr/bin/ffplay, /usr/bin/ffprobe, /usr/bin/ffserver, and /usr/bin/qt-faststart.):

Note: Git uses port 9418 by default. Make sure the Git port is unblocked in your firewall. The second-to-last command will build a .deb package named something similar to /home/user/ffmpeg/ffmpeg_201109031233-git-1_i386.deb. The installed package can be removed later, if desired, using dpkg -r ffmpeg.

Some programs may expect ffmpeg to be in /usr/bin, so create a symbolic link:

sudo ln -s /home/user/ffmpeg/ffmpeg /usr/bin/ffmpeg

Add a webcam to a screencast

To show your webcam in your screencast, install one of three webcam applications:

Cheese (sudo apt-get install cheese) is a Gnome-based webcam application with many options and a re-sizable window.

Xawtv (sudo apt-get install xawtv) is a Gtk-based application. Because the Xawtv window can be arranged so that only the webcam image is shown, it is my favorite webcam display for screencasts. (Click on "X" in the window bar -> Advanced -> No Border (ticked) .)

Any of these applications can be used in (K)Ubuntu.

Start the desired application until your webcam is showing. Position the webcam image on your desktop as desired. Now start your screencapture and the webcam window will be included.

Record microphone and speaker output simultaneously

This example assumes Pulse Audio is installed on the system. This was tested on Natty.

recordMyDesktop

gtk-recordMyDesktop -- a one-step solution. Audio can be captured as well, including through the microphone (whichever inputs are enabled in the mixer/pulse audio system will be captured). Even a virtual machine like VirtualBox can send its audio through the Pulse Audio system, so it can also be captured. The recorded .ogv file can then be converted to a Flash video (.flv) with:

Using VNC to capture another computer's screen

Troubleshooting tips

A method that has worked for me in the past is the method described using Avidemux. I use either gtk-recordMyDesktop or xvidcap to capture the video, as above (saving as an .avi). The problem for me is that Avidemux is rather particular about the audio formats it will accept. I have found that it will not accept many mp3 files (depending on the codec originally used to create the mp3 file). However, I have found that if I import any mp3 file into Audacity and then re-export it as an mp3, Audacity will re-encode it with a codec (libmp3lame) that Avidemux likes.

I can therefore combine the .avi video with the .mp3 audio (created by Audacity) using Avidemux.

Screencasts in Windows

Some users will run (K)Ubuntu in a virtual machine (VirtualBox, VMWare, QEMU) in Windows. For those users who wish to record a screencast, there are two good open source screen recording utilities:

CamStudio -- works similarly to gtk-recordMyDesktop, with capabilities of converting to Flash videos (.flv and .swf). Records audio and video with options for annotation and other effects.

Wink -- essentially a screen capture, it is good for animations with each frame individually constructed. It can output to a video file, including Flash videos.

Examples

Exercise: Slideshow with audio track

This may seem a bit cumbersome, but it works for me. If you have a better method please add it! (Note: I now use the FFMPEG with x11grab method at the top of this page. This method below was how I originally did it.)

Gwenview is installed by default in Kubuntu. I then install Avidemux, Audacity, gtk-recordMyDesktop, mencoder, ffmpeg, and kubuntu-restricted-extras.

Start gtk-recordMyDesktop but do not use the sound recording portion (leave the Sound Quality box unticked). I find that gtk-recordMyDesktop audio recording is choppy and therefore less than desirable for me (even on my dual-core 64-bit system with 3 Gb RAM).

Start Gwenview and find the folder with your pics that will be made into a slideshow. Start gtk-recordMyDesktop recording and the start the slideshow (Gwenview -> View - Start Slideshow). Record until all the slides have displayed. Then stop gtk-recordMyDesktop recording. The file will be saved as an .ogv file (such as MyRecordedFile.ogv).

If you wish to join several mp3 files into a single mp3, you can concatenate them:

cat File1.mp3 File2.mp3 File3.mp3 > CombinedFile.mp3

Import the mp3 file into Audacity and edit as desired. Export the resulting edited file into a new mp3 file (such as MyAudacitySoundtrackFile.mp3). Even if you make no edits, you should re-export every mp3 using Audacity because Avidemux doesn't always recognize the codecs originally used to create many mp3s (but it always recognizes the mp3s exported by Audacity).