Hide

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.


If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Hide

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

Capture video of a linux desktop

Terminal - Capture video of a linux desktop
ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq /tmp/out.mpg
2009-02-05 17:23:43
User: wwest4
237
Capture video of a linux desktop

Alternatives

There are 3 alternatives - vote for the best!

Terminal - Alternatives
ffmpeg -f x11grab -r 25 -s 800x600 -i :0.0 /tmp/outputFile.mpg
2009-06-05 21:11:17
User: dcabanis
Tags: video X11 ffmpeg
46

Grab X11 input and create an MPEG at 25 fps with the resolution 800x600

ffmpeg -y -f alsa -ac 2 -i pulse -f x11grab -r 30 -s `xdpyinfo | grep 'dimensions:'|awk '{print $2}'` -i :0.0 -acodec pcm_s16le output.wav -an -vcodec libx264 -vpre lossless_ultrafast -threads 0 output.mp4
ffmpeg -f x11grab -s `xdpyinfo | grep 'dimensions:'|awk '{print $2}'` -r 25 -i :0.0 -sameq /tmp/out.mpg > /root/howto/capture_screen_video_ffmpeg
ffmpeg -f x11grab -s wxga -r 25 -i :0.0+1366,0 -qscale 0 /tmp/out.mpg
2013-07-31 14:07:26
User: MickO
1

This is identical to the original command, but allows you to specify an offset if you have multiple monitors. In this case you'll record a 1366x768 window that's offset by 1366 pixels in the x axis and 0 pixels in the y axis. Note also that the -sameq option has been replaced by -qscale - at least in ffmpeg version 1.2.1 on Fedora 19.

gtk-recordMyDesktop
2013-06-21 02:32:52
User: denilsonsa
0

Either use gtk-recordMyDesktop or qt-recordMyDesktop, which are GUIs for recordmydesktop command.

Know a better way?

If you can do better, submit your command here.

What others think

hmm... wtf? :

ffmpeg -f x11grab -s sxga -r 25 -i :0.0 -sameq ~/tst.mpg

FFmpeg version r11872+debian_3:0.svn20080206-12ubuntu3, Copyright (c) 2000-2008 Fabrice Bellard, et al.

configuration: --enable-gpl --enable-pp --enable-swscaler --enable-x11grab --prefix=/usr --enable-libgsm --enable-libtheora --enable-libvorbis --enable-pthreads --disable-strip --enable-libfaad --enable-libfaadbin --enable-liba52 --enable-liba52bin --enable-libdc1394 --disable-armv5te --disable-armv6 --disable-altivec--disable-vis --enable-shared --disable-static

libavutil version: 49.6.0

libavcodec version: 51.50.0

libavformat version: 52.7.0

libavdevice version: 52.0.0

built on Oct 3 2008 22:40:31, gcc: 4.3.2

[x11grab @ 0xb7ec4388]device: :0.0 -> display: :0.0 x: 0 y: 0 width: 1280 height: 1024

No protocol specified

[x11grab @ 0xb7ec4388]Could not open X display.

:0.0: I/O error occured

Usually that means that input file is truncated and/or corrupted.

Sad -:( now I have to read mans...

Comment by GreyCardinal 290 weeks and 4 days ago

FFmpeg version r11872+debian_3:0.svn20080206-12ubuntu3, Copyright (c) 2000-2008 Fabrice Bellard, et al.

configuration: --enable-gpl --enable-pp --enable-swscaler --enable-x11grab --prefix=/usr --enable-libgsm --enable-libtheora --enable-libvorbis --enable-pthreads --disable-strip --enable-libfaad --enable-libfaadbin --enable-liba52 --enable-liba52bin --enable-libdc1394 --disable-armv5te --disable-armv6 --disable-altivec --disable-vis --enable-shared --disable-static

libavutil version: 49.6.0

libavcodec version: 51.50.0

libavformat version: 52.7.0

libavdevice version: 52.0.0

built on Oct 3 2008 22:40:31, gcc: 4.3.2

[x11grab @ 0xb7f8f388]device: :0.0 -> display: :0.0 x: 0 y: 0 width: 1366 height: 768

[x11grab @ 0xb7f8f388]shared memory extension found

X Error of failed request: BadMatch (invalid parameter attributes)

Major opcode of failed request: 148 (MIT-SHM)

Minor opcode of failed request: 4 (X_ShmGetImage)

Serial number of failed request: 9

Current serial number in output stream: 9

Doesn't work for me too

Comment by manspaceunix 290 weeks and 2 days ago

I confirm that it doesn't work on Ubuntu Intrepid (ffmpeg version r11872+debian_3:0.svn20080206-12ubuntu3). I get the same trace as manspaceunix. It's because you haven't set the size to fit your needs. For example, my screen is 1024x768, so instead of "-s sxga", I have to use "-s xga" and it does it.

Comment by raphink 289 weeks and 1 day ago

Hmm, actually, I ended up using

ffmpeg -f x11grab -s sxga -r 24 -i :0.0 /tmp/out.mpg

on Ubuntu Intrepid and it works, although I find that the result blinks horribly.

Comment by raphink 289 weeks and 1 day ago

you can also use -s XxY, for example i use -s 1680x1050 on my machine.

Or, assuming you have randr, use this for the general case:

ffmpeg -f x11grab -s `xrandr | grep "Screen 0" | awk '{ print $8 }'`x`xrandr | grep "Screen 0" | awk '{ print $10 }' | sed 's/,.*//'` -r 25 -i :0.0 -sameq /tmp/out.mpg

Comment by skibrianski 288 weeks ago

Seemed to have the same video quality as gtk-recordmydesktop, but with a crappier mouse pointer.

Comment by Vadi 288 weeks ago

This works on machines without gtk-recordmydesktop (ubuntu doesn't have it, not to mention kde, xfce, etc. based environments)

Comment by skibrianski 288 weeks ago

Also, recordmydesktop doesn't work well with compiz.

Comment by skibrianski 288 weeks ago

I've used vlc in the past to record like this... Open screen:// with vlc and use its streaming features to save it.

Comment by Viaken 286 weeks and 1 day ago

looks the same with this command http://www.commandlinefu.com/commands/view/1618/record-your-desktop

Comment by tristan_ph 283 weeks and 6 days ago

I found the video looks better if played back on a different computer.

Also if you don't know the size of your scree and want to record the whole thing this variation works well.

ffmpeg -f x11grab -s `xdpyinfo | grep 'dimensions:'|awk '{print $2}'` -r 25 -i :0.0 -sameq /tmp/out.mpg

Comment by mluich 278 weeks and 6 days ago

Doesn't work in my Ubuntu 8.04

FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2007 Fabrice Bellard, et al.

configuration: --enable-gpl --enable-pp --enable-swscaler --enable-pthreads --enable-libvorbis --enable-libtheora --enable-libogg --enable-libgsm --enable-dc1394 --disable-debug --enable-shared --prefix=/usr

libavutil version: 1d.49.3.0

libavcodec version: 1d.51.38.0

libavformat version: 1d.51.10.0

built on Mar 16 2009 21:16:26, gcc: 4.2.4 (Ubuntu 4.2.4-1ubuntu3)

Unknown input or output format: x11grab

Comment by tr0k0l0 276 weeks and 4 days ago

Debian: may abort ("ffmpeg: symbol lookup error: ffmpeg: undefined symbol: ffm_nopts") if you use the debian-multimedia.org repository

See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=489209

Comment by natmaka 267 weeks and 6 days ago

this is what worked for me on debian unstable and...

FFmpeg version SVN-r20547, Copyright (c) 2000-2009 Fabrice Bellard, et al.

built on Nov 18 2009 19:13:44 with gcc 4.3.4

configuration: --prefix=/usr --extra-cflags='-Wall -g ' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-libfaad --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libtheora --enable-libdc1394 --enable-libspeex --enable-nonfree --disable-stripping --enable-avfilter --enable-libdirac --disable-decoder=libdirac --enable-libschroedinger --disable-encoder=libschroedinger --enable-avfilter-lavf --enable-libopenjpeg --enable-version3 --disable-altivec --disable-armv5te --disable-armv6 --disable-vis

libavutil 50. 4. 0 / 50. 4. 0

libavcodec 52.41. 0 / 52.41. 0

libavformat 52.39. 2 / 52.39. 2

libavdevice 52. 2. 0 / 52. 2. 0

libavfilter 1. 8. 0 / 1. 8. 0

libswscale 0. 7. 1 / 0. 7. 1

libpostproc 51. 2. 0 / 51. 2. 0

ffmpeg -f x11grab -s 1440x900 -r 15 -i :0 -vcodec libx264 -vpre normal -threads 0 ~/videofile.mp4

Comment by nadavkav 248 weeks and 6 days ago

http://superuser.com/a/478550/110524">-sameq does not mean "same quality" and has been removed upstream.

Comment by LordNeckbeard 41 weeks and 6 days ago

Your point of view

You must be signed in to comment.

Related sites and podcasts