Screencasting on Ubuntu using ffmpeg

Updated 8th January 2013: It appears that at some stage ffmpeg was forked into libav, and the latter is what is included with Ubuntu 12.04. As it turns out, the ffmpeg commands below (which are still accepted) will result in a video that is severely choppy – practically unusable. I don’t have time to get to the bottom of this, so following are two links which describe how to uninstall the libav tools bundled with Ubuntu 12.04 and how to install the original ffmpeg packages from a PPA. The original packages work fine, but a side effect is that your media playback applications may cease to function normally (the second link describes this in detail). I only use this system for video capture so for me it isn’t an issue – but as they say, your mileage may vary…

The original guide now follows.


This is a very brief guide to using the FFmpeg Linux utility to record a live screencast. I’ve used this method (which is quite well documented out there) after discovering that the recordMyDesktop utility is unsuitable in certain critical areas for my needs.

The first thing to note here is that FFmpeg consists of a suite of libraries and codecs for handling A/V media, and, the ffmpeg command line utility itself. The latter is what we will be using to capture our screencast.

Our example system is running Ubuntu Linux 11.10 x86. Note that at this stage we are only capturing live video, not live audio.

First, use Ubuntu Software Center to install FFmpeg:

Installing FFmpeg using Ubuntu Software Center

Once installed, launch a Terminal window: it’s time to enter a text command, but don’t worry, it’s straightforward and you can cut and paste the below example to get started. Simply enter the following command, noting that this will save a video recording of your live session to an example file named “testscreencast.mp4” on your Desktop.

ffmpeg -f x11grab -r 25 -s 1280x1024 -i :0.0 -sameq ~/Desktop/testscreencast.mp4

To stop the recording, press Ctrl+C with the terminal window in focus. To view the video file, you can use VLC or a similar media player.


Let’s look at the various options and parameters of the above command in more detail:

  • ffmpeg – this is the ffmpeg command itself being invoked
  • -f – force the input or output file format (note – not the file itself). In this example, we are forcing the file input format to be the X11 display (see below)
  • x11grab – use the X11 display
  • -r – frame rate in frames per second. This defaults to 25 fps
  • -s – set frame size. It can be set either as WidthxHeight pixels, (e.g. 1280×1024), or accepts a variety of preset abbreviations (e.g. sxga which corresponds to 1280×1024)
  • -i – set the input file. This does not have to be a “file” per se, and indeed in this example the input file is the value :0.0, which corresponds to the value of the $DISPLAY environment variable (in display.screen format). See: for more information
  • -sameq – this option sets the transcoding quality to be the same as the source input.

The last portion of the command simply sets the location for the output file. Also, the default video codec for ffmpeg (you’ll note that we haven’t explicitly set a codec anywhere) is MPEG-4 (note, not MPEG-4 Part 10), which for screencasts is fine.

Once you’ve captured your screencast, you can use an application like OpenShot to perform the editing.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s