Unknown input or output format: x11grab (Ubuntu)

I recompiled today ffmpeg because I wanted to have support for a couple more of formats but when I finished the installation (using the latest SVN version), I was unable to capture the screen any more. Got this error:


Unknown input or output format: x11grab

I have been searching and reading almost hundreds of pages but no one seemed to have encountered this issue before in Ubuntu 9.10, or they were able to fix it but never bothered posting about that.

Finally in an act of desperation I decided to read the configure script and looked for instances of x11. This line looked very suspicious:


x11_grab_device_indev_extralibs="-lX11 -lXext -lXfixes"

I checked (using Synaptic Package Manager) and found that although I had the X11 dev and Xext dev libraries installed on my system, I was missing Xfixes. So I installed libxfixes-dev:


sudo apt-get install libxfixes-dev

(or you can do it with Synaptic too!)

I depends on x11proto-fixes-dev, so you need to install that one as well, of course.

Then I ran configure again using this set of switches:


./configure --enable-gpl --enable-version3 --enable-nonfree --enable-postproc \
 --enable-pthreads --enable-libfaac --enable-libfaad --enable-libmp3lame \
--enable-libtheora --enable-libx264 --enable-libxvid --enable-x11grab \
--enable-libvorbis

And made sure that x11_grab_device was in the Enabled indevs section from configure's output:


Enabled indevs:
alsa            oss            v4l2
dv1394            v4l            x11_grab_device

If x11_grab_device hadn't been there (and trust me, it wasn't before installing xfixes) that would render the whole process of compiling ffmpeg useless, since it wouldn't have support for grabbing the X11 display (which is what you need for screen capturing).

Then I recompiled ffmpeg again, etc, etc... but the old examples from the manual don't seem to work any more. Their syntax needs to be adjusted:

this (from the manual):


ffmpeg -f x11grab -s cif -i :0.0 /tmp/out.mpg

gives me the following error:


[x11grab @ 0x1e0e420]device: :0.0 -> display: :0.0 x: 0 y: 0 width: 352 height: 288
[x11grab @ 0x1e0e420]AVParameters don't have video size and/or rate. Use -s and -r.
:0.0: Input/output error

It seems that now we need to specify both the size and rate for the capture. So for example this will do (note the extra -r 30 which specifies the capture rate to be 30 frames per second):


ffmpeg -f x11grab -r 30 -s cif -i :0.0 /tmp/out.mpg

Happy screen capturing! :-D