2

I want to send video to webcam device on Ubuntu which is loaded on /dev/video0

I've already seen this command that send desktop to it but is there any way to send video to it?

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

I should mention that i specifically want to use ffmpeg command.

  • It's my understanding that a webcam is an video input device so I would say no. What webcam do you have that supports receiving video? – Elder Geek Feb 8 '17 at 19:12
  • @ElderGeek there is no webcam.it is virtual one which need to have video on it. – dsddd Feb 8 '17 at 19:15
  • HAve you tried using a pipe? – Elder Geek Feb 8 '17 at 19:25
  • Information is available here – Elder Geek Feb 8 '17 at 19:29
  • 1
    Possible duplicate of Fake a webcam using a video loopback device? (although not necessarily using ffmpeg). – llogan Feb 8 '17 at 19:39
6

You can do this with v4l2loopback. If it's not in the repository for your Ubuntu version you can compile it:

sudo apt-get install build-essential checkinstall
wget https://github.com/umlaeute/v4l2loopback/archive/master.zip
unzip master.zip
cd v4l2loopback-master
make
sudo checkinstall --pkgname=v4l2loopback --pkgversion="$(date +%Y%m%d%H%M)-git" --default
sudo modprobe v4l2loopback

Now run ffmpeg. Example for desktop:

ffmpeg -f x11grab -framerate 15 -video_size 1280x720 -i :0.0 -f v4l2 /dev/video0

Example for a video input:

ffmpeg -re -i input.mp4 -map 0:v -f v4l2 /dev/video0

You can view it with ffplay:

ffplay /dev/video0

Note that the actual video number may vary depending if an existing device is already using /dev/video0.

  • where can i specify my video ? – dsddd Feb 8 '17 at 21:08
  • @dsddd Example updated. – llogan Feb 8 '17 at 21:13

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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