Recording screencasts on Debian with ffmpeg and the Blue Yeti USB Microphone

Aug 31, 2011

I needed a good setup for recording screencasts on GNU/Linux. I had earlier tried using an ordinary headset and tools like "recordmydesktop". The audio/video quality I got was poor (maybe it was because of my lack of experience dealing with media stuff in general). I decided to try something different.

First, I did some research on audio recording equipment. The general opinion seems to be that the built-in sound card introduces lots of noise into the recording - so for better quality, you had to use some kind of hardware which performed the analog-to-digital conversion stuff on its own, without depending on the PC soundcard. These devices are in general expensive (and there was little mention of compatibility with GNU/Linux). It was then that I stumbled upon a USB Mic called the "Blue Yeti" available for $99 on Amazon:

Blue Yeti on Amazon

One or two reviewers had mentioned that the mic works flawlessly on GNU/Linux! Based on these reviews, I purchased a "Yeti" a few days back:

The mic can do some interesting things, as demonstrated by this detailed review!

Getting the mic working with Debian was easy. There was some confusion with gnome-sound-recorder choosing the built-in soundcard as the default device; this was changed by creating a .asoundrc (under the login directory) which looks like this:

pcm.!default {
    type hw
    card 1
}
ctl.!default {
    type hw           
    card 1
}

The "card" number of the Yeti was identified by running "arecord -l"; the builtin soundcard was "card 0" and the Yeti was "card 1". With this change, gnome-sound-recorder had no trouble recording and playing back sound through the Yeti (the Yeti can be used as a sound output device also)!

For recording screencasts, I tried out "ffmpeg" as described in this excellent article. The basic idea is to use ffmpeg to capture the video/audio in raw format and perform compression later. As compression is the compute intensive part, not doing it in real-time makes it easy to capture at a good frame rate even on a low-end system (my PC has an AMD Sempron processor). The article explains how to use ffmpeg for screencasts on Ubuntu - I had to do one or two small tweaks to make it work on Debian.

To install the packages listed here, I had to add debian-multimedia.org to my /etc/apt/sources.list; I didn't have to compile x264 because libx264 also was available as a Debian package. Ffmpeg had to be compiled from source (I used version 0.6.3 as the latest version needed more recent versions of some of the installed libraries).

Here is the script I use for recording:

ffmpeg -f alsa -ac 2 -i hw:1,0 -f x11grab -r 30 -s $1x$2 -i :0.0+$3,$4 -acodec pcm_s16le 
-vcodec libx264 -vpre lossless_ultrafast -threads 0 $5.mkv

Note the use of "-i hw:1,0" - this is needed because I am not using pulseaudio as the input source. The numbers (1,0) were obtained by running "arecord -l" (card 0 device 1).

That's all you need to create quality screencasts on GNU/Linux!

[Subscribe to our Newsletter] [Go to pramode.net home] [Courses at Recursive Labs] [Connect with me on Twitter/Facebook]