Making screencasts on Ubuntu 12.04
This morning, my nine year old son said
"Vati, ich brauche Deine Hilfe... I want to make a "Let's
Play" video showing how to play Minecraft,
and Bandicam
always stops when the screen changes."
Since the family computer runs Ubuntu 12.04, I'm pretty sure
he wasn't actually trying to use Bandicam;
all he wanted was to do a screencast
with a microphone and the sound from the game, and then upload the
resulting video to Youtube.
Step 1: Get speakers working
For some reason, even with the
system volume set up high, no sound came out. Turns out the
workaround is to mute and then unmute the system sound.
(The problem may be triggered by switching users.
If that bug is still in Ubuntu 12.10, I'll report it...)
Step 2: Get sound working in Minecraft
That was easy - Alex
had turned the sound off in the game settings.
Step 3: Get microphone working
I plugged in an analog microphone and fired up
Sound Recorder to see if it worked.
Nothing worked at first.
I needed to go into System Settings / Sound / Input and move the
Input Volume up from zero.
Step 4: Record a short test screencast
I've had varying results with gui tools like
Kazam,
RecordMyDesktop,
and a few others listed at
omgubuntu.co.uk/tag/screencasting,
so this time I decided to do it with bare ffmpeg.
Unfortunately, I couldn't figure out how to get it
to record from the microphone!
Eventually I got it
working by downloading the source to libav,
configuring it with --enable-libpulse --enable-gpl --enable-x11grab --enable-libx264,
building it, doing
# find the pulseaudio output channel to record from
MONITOR=$(pactl list | grep -A2 '^Source #' | grep 'Name: .*\.monitor$' | awk '{print $NF}' | tail -n1)
# find the pulseaudio input channel to record from
MIKE=$(pactl list | grep alsa_input | awk '{print $2}' | tail -n1 )
# find out what size the screen is set to
RESOLUTION=$(xrandr 2>/dev/null | grep current | sed 's/.*current //;s/,.*//;s/ x /x/')
avconv \
-f x11grab -r 15 -s $RESOLUTION -i 0:0 \
-f pulse -i $MONITOR \
-f pulse -i $MIKE \
-filter_complex amix=inputs=2:duration=first:dropout_transition=3 \
-vcodec libx264 -pre ultrafast \
-acodec pcm_s16le \
-y foo.$$.avi
and then making up for the fact that I hadn't actually installed it by
copying a the ultrafast preset files from the source tree to ~/.avconv,
using strace to see what it wanted.
As it turns out, both recordmydesktop and kazam were able to record
proper screencasts with sound, so I probably should have just used
them :-) Kazam has the more polished interface.
Step 5: Edit the recording
Ah, Linux video editing. I tried
Pitivi,
Lombard,
and
OpenShot,
but none of them were able to play back recordings made by any
of my tools. Avidemux, while ugly,
did actually work using these steps:
- use "xrandr -s 1024x768" to reduce the screen resolution,
or the video will be too tall to edit with avidemux!
- start the recording
- run the game and narrate the screencast
- quit the game and stop recording
- use "xrandr -s 0" to make the screen high resolution again
- start avidemux
- import video file
- Play to the begin cut point and click on "A"
- Play to the end cut point and click on "B"
- Click Edit / Cut. (Repeat these steps for everything you need to cut
out. Note that moving the slider to a cut point won't work, the slider
has to have set by playing to the cut point and pressing Pause.)
- Change the video and audio settings from "Copy" to
"MPEG-4 ASP (avcodec)" and "MP3 (lame)", and change the output format
to "MP4". (Other settings may work, but leaving it on the defaults
causes saved files to be totally black!)
-
Save the file, being sure to add .mp4 on the end.
Step 6: Upload to youtube
Then wait a few minutes for youtube to finish processing
And voila! Working screencasts.
See Also
Copyright 2012 Dan Kegel
[email protected]
Last updated: 4 Nov 2012
[Return to www.kegel.com/linux]