Wednesday, December 25, 2013

Grabbing X11 display into an mpg file (example from ffmpeg man pages Ubuntu)

I didn't know this had been integrated or that there was a method for ffmpeg input to be the x display.

EXAMPLES

   Video and Audio grabbing
       If you specify the input format and device then ffmpeg can grab video and audio directly.

               ffmpeg -f oss -i /dev/dsp -f video4linux2 -i /dev/video0 /tmp/out.mpg

       Note that you must activate the right video source and channel before launching ffmpeg with any TV viewer such as
        xawtv ("http://linux.bytesex.org/xawtv/") by Gerd Knorr. You also have to set the audio recording levels correctly with a standard mixer.

   X11 grabbing
       Grab the X11 display with ffmpeg via

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

       0.0 is display.screen number of your X11 server, same as the DISPLAY environment variable.

               ffmpeg -f x11grab -s cif -r 25 -i :0.0+10,20 /tmp/out.mpg

       10 is the x-offset and 20 the y-offset for the grabbing.

               ffmpeg -f x11grab -follow_mouse centered -s cif -r 25 -i :0.0 /tmp/out.mpg

       The grabbing region follows the mouse pointer, which stays at the center of region.

               ffmpeg -f x11grab -follow_mouse 100 -s cif -r 25 -i :0.0 /tmp/out.mpg

       Only follows when mouse pointer reaches within 100 pixels to the edge of region.

               ffmpeg -f x11grab -show_region 1 -s cif -r 25 -i :0.0+10,20 /tmp/out.mpg

       The grabbing region will be indicated on screen.

               ffmpeg -f x11grab -follow_mouse centered -show_region 1 -s cif -r 25 -i :0.0 /tmp/out.mpg

       The grabbing region indication will follow the mouse pointer.

Grabbing input from other devices:

http://ffmpeg.org/ffmpeg.html

Video and Audio grabbing

If you specify the input format and device then ffmpeg can grab video and audio directly.
ffmpeg -f oss -i /dev/dsp -f video4linux2 -i /dev/video0 /tmp/out.mpg
Or with an ALSA audio source (mono input, card id 1) instead of OSS:
ffmpeg -f alsa -ac 1 -i hw:1 -f video4linux2 -i /dev/video0 /tmp/out.mpg
Note that you must activate the right video source and channel before launching ffmpeg with any TV viewer such as xawtv by Gerd Knorr. You also have to set the audio recording levels correctly with a standard mixer.

No comments:

Post a Comment