Sunday, December 24, 2006

Desktop Recording Crusade

It's simple enough. One wants to make a video of what they're doing on the desktop and post it on the Internet. Just record the content of my desktop for the video source, and capture the output of my sound card as the audio source. Encode it, and I can upload it to a site of my choosing. It should be simple.

sudo aptitude install istanbul

No hitches. I was trying to capture video and istanbul captured this instead:

$ istanbul (272, 395) - (732, 795) DEBUG: final pipeline: oggmux name=mux ! filesink location=/tmp/tmpWSGyA4 istximagesrc startx=272 starty=395 endx=731 endy=794 name=videosource use-damage=false ! video/x-raw-rgb,framerate=10/1 ! videorate ! ffmpegcolorspace ! videoscale method=1 ! video/x-raw-yuv,width=460,height=400,framerate=10/1 ! theoraenc ! queue ! mux. gconfaudiosrc name=audiosource ! audioconvert ! vorbisenc ! queue ! mux. (istanbul:4147): GStreamer-CRITICAL **: gst_caps_get_structure: assertion `GST_IS_CAPS (caps)' failed Segmentation fault (core dumped) $

The times it did run, Istanbul decided to capture video and not write it to disk. Sometimes Istanbul was too stuck up to even capture video. So I decided to try recordMydesktop. I know its a Debian package I'm trying to install on Ubuntu, but compiling is a last resort and Debian packages work most of the time.

$ sudo dpkg --install recordmydesktop_0.3.0r2-1_i386.deb dpkg: error processing recordmydesktop_0.3.0r2-1_i386.deb (--install): cannot access archive: Permission denied Errors were encountered while processing: recordmydesktop_0.3.0r2-1_i386.deb $

dpkg seems to dislike the way I mounted sshfs. So it was copied to the hard drive and recordMydesktop and gtk-recordMydesktop were installed.

Now the moment of truth!



...and nothing. So the FAQ on the homepage says:

If the frontend doesn't start at all, it is most likely that you haven't got installed gnome-python-extras.
Run gtk-recordMyDesktop on a terminal. If it says something like egg.TrayIcon is not found, then
your problem is definately that one.

So I try that and get this:

$ gtk-recordMyDesktop
Traceback (most recent call last):
File "/usr/bin/gtk-recordMyDesktop", line 30, in ?
from recordMyDesktop import rmdSimple
ImportError: No module named recordMyDesktop
$

Maybe I can get it from the command line instead of using the frontend:

$ recordmydesktop --help

Usage:
recordmydesktop [-h| --help| --version| -delay n[H|h|M|m]| -windowid id_of_window|
-display DISPLAY| -x X| -y Y|-width N| -height N| -fps N(number>0)| --on-the-fly-encoding|
-v_quality n| -s_quality n| -v_bitrate n| --no-framedrop| -dummy-cursor color|
--no-cursor| -freq N(number>0)| -channels N(number>0)| -device SOUND_DEVICE|
--no-sound| --with-shared| --no-cond-shared| -shared-threshold n| --full-shots|
--quick-subsampling| -workdir DIR| --zero-compression| --no-wm-check| --overwite| -o filename]^filename


General Options:
-h or --help Print this help and exit.
--version Print program version and exit.

Image Options:
-windowid id_of_window id of window to be recorded.
-display DISPLAY Display to connect to.
-x X Offset in x direction.
-y Y Offset in y direction.
-width N Width of recorded window.
-height N Height of recorded window.

-dummy-cursor color Color of the dummy cursor [black|white]
--no-cursor Disable drawing of the cursor.
--with-shared Enable usage of MIT-shared memory extension at all times.
--no-cond-shared Do not use the MIT-shared memory extension when aquiring large areas.
-shared-threshold n Threshold over which shared memory is used(default 75).
--full-shots Take full screenshot at every frame(Not recomended!).
--quick-subsampling Do subsampling of the chroma planes by discarding,not averaging.
-fps N(number>0.0) A positive number denoting desired framerate.

Sound Options:
-channels N(number>0) A positive number denoting desired sound channels in recording.
-freq N(number>0) A positive number denoting desired sound frequency.
-device SOUND_DEVICE Sound device(default hw0:0).
--no-sound Do not record sound.

Encoding Options
--on-the-fly-encoding Encode the audio-video data, while recording.
-v_quality n A number from 0 to 63 for desired encoded video quality(default 63).
-v_bitrate n A number from 45000 to 2000000 for desired encoded video bitrate(default 45000).
--drop-frames Allow theora encoder to drop frames.
-s_quality n Desired audio quality(-1 to 10).

Misc Options:
--no-wm-check Do not try to detect the window manager(and set options according to it)
--zero-compression Image data are always cached uncompressed.
-workdir DIR Location where a temporary directory will be created to hold project files(default $HOME).
-delay n[H|h|M|m] Number of secs(default),minutes or hours before capture starts(number can be float)
--overwrite If there is already a file with the same name, delete it
(default is to add a number postfix to the new one).
-o filename Name of recorded video(default out.ogg).

If no other options are specified, filename can be given without the -o switch.


I estimate the amount of time I would have to spend experimenting with all of the options and it's much for me to invest. So I hunker down and try this out:

$ recordmydesktop -o test.ogg
Initial recording window is set to:
X:0 Y:0 Width:1440 Height:900
Adjusted recording window is set to:
X:0 Y:2 Width:1440 Height:896
Your window manager appears to be beryl


Detected 3d compositing window manager.
Reverting to full screen capture at every frame.
To disable this check run with --no-wm-check
(though that is not advised, since it will probably produce faulty results).

Initializing...
Playback frequency 22050Hz is not available...
Using 44100Hz instead.
Recording on device hw:0,0 is set to:
2 channels at 44100Hz
Capturing!
An error occured while reading sound data:
Input/output error
Shutting down.Saved 174 frames in a total of 182 requests
.An error occured while reading sound data:
Input/output error
An error occured while reading sound data:
Input/output error

An error occured while reading sound data:
Input/output error
An error occured while reading sound data:
Input/output error
An error occured while reading sound data:
Input/output error
An error occured while reading sound data:
Input/output error
An error occured while reading sound data:
Input/output error
An error occured while reading sound data:
Input/output error
An error occured while reading sound data:
Input/output error
Killed
$

Now since I am using Beryl, I don't expect it to be perfect. But it didn't catch my sound hardware correctly. Testing with Beryl worked, but only if --no-sound was specified. Time to consult the FAQ again:

In order to record sound from a source(e.g. microphone) you have to set it
through a mixer like kmix, gnome-mixer or alsamixer. recordMyDesktop will
not set anything itself but it will rather start recording from any preselected
source.
To test if you can record you can run cat /dev/dsp on a terminal session
It should start printing characters whenever sound reaches your selected source.
Another reason for no sound might be the presence of more than one soundcards.
In that case make sure you've set the right one (consult the manpage on how to do this).

Oh, okay:

Sound Options:

-channels N(number>0)
A positive number denoting desired sound channels in recording.

-freq N(number>0)
A positive number denoting desired sound frequency.

-device SOUND_DEVICE
Sound device(default hw0:0).

--no-sound
Do not record sound.

I don't see anything about that in the man page. Time to try another method of capturing. Hmm...xvidcap uses ffmpeg to encode captured video and audio. Nice. Let's try that.

$ sudo apt-get install xvidcap
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Couldn't find package xvidcap

So I downloaded xvidcap_1.1.3-1_i386.deb from somewhere else and went on.

$ xvidcap
xvidcap: error while loading shared libraries: libpng.so.2: cannot open shared object file: No such file or directory

It turns out the Debian repository linked from xvidcap's homepage only has 1.1.3, which is linked to libpng.so.2. xvidcap 1.1.4, from the Sourceforge page, loads fine.

So let's start recording! I press the record button and:

$ xvidcap
xtoffmpeg.c guess_input_pix_fmt(): image depth 32 not supported ... aborting

...which I find odd because I'm running at 24 bits per pixel. The next time I run it I can capture video, but not audio! There seems to be a theme.

I found that the actual device to point xvidcap to was /dev/audio. So now I have audio and video.

Now to enjoy the fruits of my labor!



I give up.

2 comments:

xbasket said...

Yes, I know the feeling. The blog I'm running xinabox,
is filled with similar frustrations.

Cortez said...

I'm having difficulties in recording sound with xvidcap, just landed on your blog. I tried with device /dev/audio but it did not work ..... :(