Search This Blog

Wednesday 23 September 2009

screen grab with ffmpeg

screenCapture-no sound

http://www.binrev.com/forums/index.php?app=blog&module=display&section=blog&blogid=5&showentry=123&#comment54

i am always having to look this up. now at least i'll have it here:

ffmpeg -f x11grab -vc theora -s vga -r 24 -b 1200 -g 300 -i :0.0 ~/Videos/screenCapture1.ogv



option by option:

-f x11grab = take video from X...ffmpeg must have been compiled with enable-x11grab included; your distro or version may or may not have this enabled!

-vc = Video Codec...usually you will have ogg theora, xvid, [ff]mpeg (the default), and x264 available

-s = size. see the ffmpeg man page for details; vga is something like 800x600 and there are many other sizes available. know that it starts from the top left corner counts pixels from there.

-r = frame rate. lower frame rate gives smaller file size but looks a little less smooth

-b = bitrate. higher bitrate looks better but makes for a larger file size

-g = GOP size...300 provides a pretty nice looking image without increasing file size too much; it's got one intra frame every...i dunno....300/24 = 12.5 seconds or so.

-i = input...in this case it's :0.0 meaning your main screen. or display. or whatever it's called.


As you can imagine, there are a LOT more options available to you via man ffmpeg. Probably the most notable would be the offset, so if you wanted the capture area to not start at the very top left, you could tell it to, say, go down 10 pixels and over 10 pixels and THEN capture vga-size images, or xga-size images, or whatever.

## this works for me##

ok@debian800:~$ ffmpeg -f x11grab -s 400x300 -r 24 -b 1200 -g 300 -i :0.0 ~/screenCapture.mpg
ok@debian800:~$ ffmpeg -f x11grab -s 400x300 -r 24 -b 1200 -g 300 -t 60 -i :0.0 ~/clive-mplayer-terminator.mpg
ffmpeg -f x11grab -s 1280x1024 -qscale 1 -s 640x480  -r 24 -b 1200 -g 300 -t 60 -i :0.0 ~/screenCapture-scaled-to-640x480-timer-60-no-sound.mpg

## options ##

##option to capture full screen and scale. cpu depending :)
## -s 1280x1024 -qscale 1 -s 640x480

## set record time to 60 seconds
## -t 60

#http://www.elpauer.org/?p=261  ##note: has the off set at +480.200 to move the capture area
#ffmpeg -f x11grab -y -r 12 -s 800x600 -i :0.0+480,200 -vcodec ffv1 -sameq ./out.avi

## the star of the show ## great performance on my old 800mhz ppc ##
ffmpeg -f x11grab -s 1280x1024 -qscale 1 -s 640x480  -r 24 -b 1200 -g 300 -t 60 -i :0.0 ~/screenCapture.mpg