a script for recording screencasts with ffmpeg (video+audio)

Igor Chernenko igor.chernenko at gmail.com
Tue Jun 2 12:56:07 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:
http://n2.nabble.com/How-to-record-sound-on-Ubuntu-8.04%2C-8.10%2C-9.04-td2988982.html#a2988982

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.
See:
HOWTO: Install and use the latest FFmpeg and x264
http://ubuntuforums.org/showthread.php?t=786095

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,
Igor
-------------- 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:

https://bugs.launchpad.net/ubuntu/+source/recordmydesktop/+bug/339648


    * recordSoundAndDesktop.sh (1.3 KiB, text/x-sh)
      http://launchpadlibrarian.net/23829577/recordSoundAndDesktop.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:
recordSoundAndVideo.sh myvideo

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

https://bugs.launchpad.net/ubuntu/+source/recordmydesktop/+bug/339648

http://launchpadlibrarian.net/23829577/recordSoundAndDesktop.sh

The script "recordSoundAndDesktop.sh" 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...
Name: my-shooting-script-norm.sh
Type: application/x-sh
Size: 3901 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20090602/2ed67bf1/attachment.sh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: my-usb-shooting-script-norm.sh
Type: application/x-sh
Size: 3858 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20090602/2ed67bf1/attachment-0001.sh>
-------------- next part --------------

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

Bash scripts to record screencasts:

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

2. my-usb-shooting-script-norm.sh (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
http://shibuvarkala.blogspot.com/2009/04/howto-make-ubuntu-904-jaunty-jackalope.html

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:
           http://n2.nabble.com/How-to-record-sound-on-Ubuntu-8.04%2C-8.10%2C-9.04-td2988982.html

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:
http://n2.nabble.com/How-to-record-sound-on-Ubuntu-8.04%2C-8.10%2C-9.04-td2988982.html

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

See:
http://en.linuxreviews.org/MPlayer
http://howto.wikia.com/wiki/Howto_combine_multiple_video_or_audio_files
http://www.misterhowto.com/index.php?category=Computers&subcategory=Video&article=join_with_mencoder
http://www.aip.de/~arm2arm/howto/video_edit.html
http://howto-pages.org/ffmpeg/
http://www.wikihow.com/Use-FFmpeg
http://web.njit.edu/all_topics/Prog_Lang_Docs/html/mplayer/encoding.html

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