Linux – Using desktop as fake webcam on linux

ffmpeglinuxscreencastsvirtual-webcam

I want to make a live stream of (a window on) my linux desktop using a free streaming site, using the captured video as a fake webcam. There are many tools for this on windows. ffmpeg allows me to capture input on a specific window, but I can't find a way to output the video to a fake webcam-style device usable by flash.

Can anyone recommend a method (or software) for doing this?

Best Answer

You can install v4l2loopback. It is a kernel module that simulates a webcam. Load it with:

modprobe v4l2loopback

Then you need to send the video stream to the device /dev/video0 using a program like ffmpeg. In order to capture the desktop and forward it to /dev/video0 with ffmpeg, you can use the following command line:

ffmpeg -f x11grab -r 15 -s 1280x720 -i :0.0+0,0 -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video0

Change the value of -r from 15 to something else if you want a different frame rate. The resolution is chosen in the -s parameter. If you want to specify an offset from the upper-left corner of the screen, pass it in the -i parameter in the form "-i :0.0+x,y", where x and y are the horizontal and vertical offset respectively.

Related Question