I've been playing with recordmydesktop lately in order to put some suitable screencasts together for demonstrating various Linux-related activities to university students next week.
Unfortunately, both Fedora 11 and Ubuntu Jaunty have issues with RecordMyDesktop -- the current version (0.3.8.1) is much better than the last version I tried (0.3.5) in terms of both video and audio quality, but the more-than-occassional
Broken pipe: Overrun occurred.
Cause audio to be clipped rather badly.
The default settings make the video speed up and therefore finish well before the audio too -- so I set about trying to find the optimium settings to make the best encode I could.
First, if you are using a 3D Window Manager (such as Compiz), please use the --on-the-fly-encoding and --full-shots options, or everything from opening new windows to redrawing your background will end up with corruption.
If you do not know which Window Manager you are running, you can use the Visual Effects tab of the Appearence Preferences window.
If the button is in the first box (None) then you are not running a 3D Window Manager, if it is in either the Normal or Extra boxes, you are.
Now we've figured out if we need the options for 3D Window Management, it's time to move on to the audio -- in it's default configuration, the program will clip and/or drop audio because of the overrun mentioned above, but you can reduce that by a fair proportion by either:
- Using pasuspender to launch the program. This particular solution was suggested by an Ubuntu developer on a reported bug about RecordMyDesktop that looks very similar to the particular issue we're covering here.
- Configuring an .asoundrc file to use PulseAudio for all ALSA based audio by default.
The latter is done by creating a new blank file in your home directory and adding the following code:
pcm.!default {
type pulse
}
ctl.!default {
type pulse
}
Save the file, exit, log out of your session and login again.
This alone reduced the dropped audio from 7 occassions in one minute's worth of recorded footage to 3.
The former is done by adding: pasuspender -- to the beginning of the command line.
On my laptops, using pasuspender made no real difference to the problem, which is why we're preferring the .asoundrc solution for the remainder of this discussion.
Another thing that helps lower the frequency of audio dropouts is to increase the buffer size used by RecordMyDesktop -- the defaults are 4k, raising that to 16k helps dramatically, but any higher doesn't seem to offer that much of an improvement (I tried 32k (32769) and 64k (65538) when testing -- i'm only recording two channels on an internal microphone though, your milage may vary)
You can do this by adding the --buffer-size 16384 option to the command line.
update (2009-05-17): At the highest quality audio and video settings, 16384 can still cause dropouts, so 65538 is now preferred.
Next, if you're using onboard audio (like Altec Lansing laptop audio) you may see:
Playback frequency 22050Hz is not available...
Using 44100Hz instead.
Recording on device hw:0,0 is set to:
2 channels at 44100Hz
The Altec Lansing Audio, as well as several other Intel based sound cards that use the hda-intel-audio driver, will resample 44100Hz input to 48000Hz, hence the error.
To fix that, you pass --freq 48000, which allows recording of audio without any extra resampling.
Now, if you've used the pasuspender solution above, or your audio seems to be correctly synced, you can move on to the next section.
If, on the other hand -- you still see Buffer Overrun errors, or your audio is out of sync, or you use my .asoundrc solution above, you'll need to pass an additional audio-related option on the command line:
-device plughw:0,0
Using plughw, allows ALSA and PulseAudio's internals to handle all of the resampling work -- or endian-conversion work automatically, which reduces a painfully large ALSA configuration that will differ on every soundcard on the market, to a single configuration change for our purposes.
The 0,0 (aka. use the first detected virtual sound device) should be fine for almost everyone working on a standard configuration -- if you've got:
- More than one Soundcard.
- Have used the Systemwide PulseAudio On Ubuntu HOWTO to add a software equalizer to your configuration.
You may have more than one plughw device to choose from -- choosing which one is beyond the scope of this article though.
Now we can move onto improving the video quality.
Next, it helps to set the framerate -- i've seen numerous articles on the web about this, everyone suggesting everything from 10fps to 90fps to get a clear picture.
I tried 10, 12, 20, 25, 29, 50 and 60 (these seem to be the ones that are mentioned the most, in a four page Google search on the subject) -- 10 works if you want to keep the filesize low, but the playback video seems too jerky -- 60 doesn't increase the filesize, but does have an unwanted side-effect of the video finishing well before the audio when you play it back.
The optimum setting I found was --fps 20.
Finally, because I wanted to re-encode these for different purposes, I like to do the initial encoding with the highest quality possible.
However, the difference between -v_quality 1 and -v_quality 63 was minimal at best on my 1280x800 resolution.
Somewhat obviously though, the -v_bitrate option makes A LOT of difference, so I bumped that to the highest number available (2000000).
The recommended command line(s)
I've provided both a high and low quality setting for those people who are interested
The final command line, that works for me and provides the highest quality, lowest distortion with no dropouts -- was:
recordmydesktop --on-the-fly-encoding -v_quality 63 -v_bitrate 2000000 -s_quality 10 --full-shots --fps 20 --freq 48000 --buffer-size 65538 -device plughw:0,0
For a smaller filesize or for encoding on older or busier machines, with quality suitable for downloading or streaming, you can use:
recordmydesktop --quick-subsampling --on-the-fly-encoding -v_quality 10 -v_bitrate 50000 -s_quality 1 --full-shots --fps 10 --freq 48000 --buffer-size 16384 -device plughw:0,0
This option does the encoding after the video capture has stopped, which results in a smaller filesize at the expense of taking longer to encode your original footage, you can offset this somewhat by adding the --quick-subsampling option to your command line, which saves CPU time by discarding extra pixels when calculating the chroma values during the encoding process.
note: If you are using a 2D Window Manager (such as Metacity), you may omit the --full-shots option, which halves the filesize on my Ubuntu Jaunty Jackalope install.
Why No Examples?
Google doesn't support Theora based videos to be uploaded to Blogger, I had two videos recorded of 10 seconds each, the low quality one (using the settings above) clocked in at 220 kilobytes, the high quality one was 1.3 megabytes.
When El Goog does decide to allow Theora based videos on Blogger, i'll post them -- but converting them to .mp4's just to show you all what they looked like, seemed rather purpose defeating :)
5 comments:
Hey man, just wanted to tank you for this awesome post and solution. You really helped me out here, thanks :)
Now I can create my awesome video tuts :D
I have found that the recordmydesktop error causing the soundtrack to skip at random, which shows up in the terminal,
Broken pipe: Overrun occurred.
happens only when the number of channels is set to 2. If you set only 1 channel this error never happens and the soundtrack is perfect.
My system is a HP DV-3 laptop with HDA Intel soundcard running the latest recordMyDesktop (0.3.8.1) on Karmic 9.10 + Compiz 0.8.4, using PulseAudio 0.9.21 and ALSA 1.0.21.
Any ideas why 2 channels is causing this problem?
recordmydesktop_now: I had that on my DV5 until I installed the ALSA backport driver packages with Karmic -- once i'd done that, I get far less overrun errors unless something is blocking the soundcard, usually Rhythmbox or VMWare/VirtualBox.
Dude, thanks for sharing. However I do think that the playback speeds of the video are caused by recordmydesktop skipping frames due to the CPU overloading caused by on-the-fly encoding.
So, your settings might work well for on the fly encoding on your system, but that doesn't guarantee that they'll be fine on other systems.
Eg: on my system your command generates a highly faster video.
Just my 2 cents,
Fabio Varesano
fabio, you're my hero!
thanks!
Post a Comment