Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I want to record my desktop, I use:

ffmpeg -f x11grab -s `xdpyinfo | grep -i dimensions: | sed 's/[^0-9]*pixels.*(.*).*//' | sed 's/[^0-9x]*//'` -r 25 -i :0.0 -sameq valami.avi

But it doesn't save any audio -- how can I include sound with the video?

Extra: How can I set on-the-fly encoding like with x264 + mp3:128kbit?

share|improve this question
have you seen this question? unix.stackexchange.com/questions/3490/… – Mike Pennington Jun 14 '11 at 13:02
For the screen resolution, a more compact way than grep + sed + sed is to use awk: xdpyinfo |awk '/dimensions:/{printf $2}' – Peter.O Jun 14 '11 at 20:39
The link given by @Mike works for pulseaudio. I'd like to see a solution for us using alsa :) – invert Aug 5 '11 at 15:50

Just add -ad device_you_want_to_record

You might also want to tweak your audio codec.

This site has good examples: https://verb3k.wordpress.com/2010/01/26/how-to-do-proper-screencasts-on-linux/

share|improve this answer
I don't know what my -ad device needs to be, but it works without it when I use pavucontrol as per the link ... thanks ... How can I find out what my -ad device is? ... and perhaps more to the point, I don't see this -ad option in my man ffmpeg .. FFmpeg version SVN-r0.5.1-4:0.5.1-1ubuntu1.1 – Peter.O Jun 15 '11 at 4:20
-ad should only apply to alsa, with pulse audio you shouldn't need to set that (not 100% sure, since I don't use pulse audio). – Let_Me_Be Jun 15 '11 at 6:58

I recently became interested in screencasting, and stumbled upon http://screencasts.ubuntu.com/ at which they recommended installing gtk-recordMyDesktop. So I did, and tried it out and it worked, audio and all. My humble results at http://www.youtube.com/watch?v=Rju2TEfG0Bo (includes audio). It may use your technique under the covers for all I know.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.