I am running motion on my raspberry pi using the V4L2 driver. While motion is running, I can't take a snapshot using raspistill. Is is possible to take a snapshot of the virtual V4L2 device using another tool while motion is running?

I guess /dev/video0 (created by V4L2) should be accessible by multiple clients? But which tool would I use to take a snapshot?

  • Do you get any output from v4l2-ctl -d /dev/video0 --list-formats?
    – Wilf
    Commented Jun 30, 2014 at 11:19

1 Answer 1


You should look to v4l2loopback in order to allow to open "twice" a V4L2 device.

1 - It will allow to create a virtual video device using :

sudo apt-get install v4l2loopback-dkms    
sudo modprobe v4l2loopback video_nr=10

This will add a new device /dev/video10

2 - Next you will need to copy the real device (/dev/video0) to the virtual one (/dev/video10) using ffmpeg or gstreamer.

  • using ffmpeg
sudo apt-get install ffmpeg
ffmpeg -f video4linux2 -i /dev/video0 -vcodec copy -f v4l2 /dev/video10
  • using gstreamer
sudo apt-get install gstreamer1.0-tools gstreamer1.0-plugins-good
gst-launch-1.0 v4l2src device=/dev/video0 ! v4l2sink device=/dev/video10
  • using v4l2tools (some of my tries with V4L2 programming)
git clone https://github.com/mpromonet/v4l2tools
sudo apt-get install liblog4cpp5-dev
make v4l2copy
./v4l2copy /dev/video0 /dev/video10

3 - Finally the v4l2loopback virtual device, that could be openned severals times,
could be used by motion and an other one to take snasphot (for instance using webcam or v4l2grab)

  • thanks to everyone here. I broke my installation so I couldn't test it yet, but this sounds very well - let's hope the resource consumption won't be too high. Commented Jul 7, 2014 at 20:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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