script for recording screencasts with ffmpeg (video+audio)

Igor Chernenko igor.chernenko at
Tue Jun 2 12:42:39 UTC 2009

Dear friends,

I created a script for recording screencasts on Ubuntu 9.04.
I believe it might be useful.

It works well. The quality is good.
The screencasts can be published without any editing or noise removal.

Using the script, an ordinary user can easily produce a good
screencast with minimal efforts.
No expensive hardware is required.

In the Attachment: the script (two versions), howto

Screenshots + howto are here:

One may need these screenshots to understand how to capture audio with ffmpeg

The script works on Ubuntu 9.04
It runs two ffmpegs, one capture screen, another records audio.
Then avi file (video+audio) is created.
This version of the script includes filtering and normalization (SoX
with Ladspa plugs).

One can also run the script on Ubuntu 8.04, or 8.10, but
this would require recompilation of ffmpeg.
HOWTO: Install and use the latest FFmpeg and x264

To be fair, I am completely ignorant in shell scripting.
I just re-used somebody's script.
Therefore, I would be happy to hear any advice about how to improve the script.

Best regards,
-------------- next part --------------

The origin of the script:

I am not a guru of Linux shell scripting.
I simply re-used somebody's script.
The author of the original script wrote: 
"I'm no bash script expert, so check if everything is OK before running it".

Source of the script:

    * (1.3 KiB, text/x-sh)

Just in case anyone arrives here with the same problem I'm reporting, I'm currently using a workaround: using arecord to record audio and recordmydesktop to record video only.

I made a bash script (I'm no bash script expert, so check if everything is OK before running it) that, when called, runs both programs in the background and when you press ENTER it finalizes both processes, waits for recordmydesktop to finish encoding the video and uses mencoder to merge audio and video into an AVI.

Usage: myvideo

(If the name of the video is not specified, it uses a default name)

The script "" seems to be designed to synchronize audio and video output.
I tested the script. My conclusion: audio and video are not synchronized.

I "re-used" this script, actually, changed it essentially.

My script does synchronize audio and video, I believe.
Instead of arecord (alsa-record), I utilized ffmpeg to record from OSS.
The reason is simple. OSS does not produce such amount of noise as AlSA.

-------------- next part --------------
A non-text attachment was scrubbed...
Type: application/x-sh
Size: 3901 bytes
Desc: not available
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Type: application/x-sh
Size: 3858 bytes
Desc: not available
URL: <>
-------------- next part --------------

How to record video tutorials (high quality screencasts) on Ubuntu 9.04

Bash scripts to record screencasts:

1. (capture screen and record audio from /dev/dsp - OSS, the internal sound card)

2. (capture screen and record audio from /dev/dsp1 - OSS, the external USB sound card)

To run the scripts you have to install ffmpeg, SoX, and Steve Harris's LADSPA plugins (swh-plugins).

Step 1: Make your Ubuntu multimedia ready

How to make Ubuntu 9.04 (Jaunty Jackalope) Multimedia Ready

Step 2: Install SoX

sudo apt-get install sox 

Step 3: Install Steve Harris's LADSPA plugins (swh-plugins)

sudo apt-get install swh-plugins

Step 4: Read my post about how to record sound on Ubuntu:

Step 5. Run my script to record screencast

The script (two versions) is in the Attachment. Howto is inside the script.

The script produces 4 files:

1. wave
2. wave (filtered and normalized)
3. avi (only video)
4. avi (video+sound)

Noise removal is not necessary if you follow the method described in my post:

In any case, wave can be edited with Audacity.
AVI can be edited with ffmpeg or mencoder


If you hate command line tools, you can edit AVI with Avidemux (install it with Synaptic).
Avidemux has a nice GUI, but the quality of video might be reduced during editing.

Avi and wave can be easily merged into AVI (video+sound) with this command:
ffmpeg -isync -i input.wav -i input.avi -acodec mp2 -ab 192k -vcodec copy output-final.avi

In a word, VLC allows to play a video with "external audio file".

More information about the ubuntu-users mailing list