CRI Radio

Apr 23, 2007

V4L2 Virtual Device (v4l2vd)

V4L2 Virtual Device (v4l2vd)

http://v4l2vd.sourceforge.net/

Description

V4L2 Virtual Device is a video4linux2 driver providing one or multiple video pipes. It is used to route the output of a user space video source application to typical video “consuming” applications (players, encoders, PVRs) that normally get their content from video4linux2 devices. Through v4l2vd, applications such as mplayer, mythTV and many other can now access and render video files or real-time networked media sources. In addition to the v4l2vd driver, the v4l2vd Source application is provided with this project as an example of a raw video feed.

This project was developed based on the Video4Linux Loopback Device project by Jeroen Vreenken and Kenneth Lavrsen which we thank here for their very useful contribution:

We decided to launch this project mainly for three reasons:

  • Simplify our work: we decided to go straight to implementing v4l2 functionality without regards to backward compatibility with v4l1. Maintaining backward compatibility in V4L Loopback would probably have required a much more substantial effort.

  • We have seen recently many discussions in the open source community where the need for a tool such as v4l2vd was expressed. We feel it is better to release our code early than to try to reach backward compatibility with V4L Loopback (we actually don’t have the resources to do it at this point anyway).

  • The Video 4 Linux Loopback Device is no longer actively maintained

Contact

Jean-Michel Bouffard (jmbouffard at users dot sourceforge dot net) from the Communications Research Centre (CRC), Canada. V4L2 Virtual Device is developed at the CRC, and is released as Open Source Software under the GNU General Public License. For support requests about v4l2vd, please use the forum.

image



Video4Linux Loopback Device

Original author: JeroenVreeken

Uploaded to TWiki first time by KennethLavrsen

Introduction

The video4linux device is a driver that implements a video pipe using two video4linux devices

Jeroen Vreeken wrote this driver for debugging motion realtime, which worked very nice and he decided to make something usefull of it. You can use this driver for looking at motion in realtime or for feeding a webcam while still securing your room.

Note also that vloopback output can be used by several applications at the same time (see below)

Detailed Description

The video4linux device is no longer actively being maintained. But since there is still some demand for it and still some people that make small patches for it the new Motion maintainers decided to gather these patches in a new release. If you need support do not ask the current motion maintainers. Instead join the motion mailing list where there is a reasonable chance to find help.

The following applications supports piping a video feed to vloopback:

These applications that can read the output of vloopback:

  • setv4l (Jeroen's program for changing the settings of a video device)
  • vidcat (part of the w3cam package)
  • camstream (a nice video viewer).
  • Xawtv also works, but you might have to tell it the size e.g. 'xawtv -c /dev/videoN -geometry 176x144'.
  • EffecTV An amazing real-time video effector.
  • Motion (feeding a second motion process the output of the first gives neat effects)

How to use multiple webcam applications with vloopback

1) A simple example (all applications use the same resolution) Do "modproble vloopback" then "resize /dev/video0 /dev/video1 320x240 320x240". Now, you can run as many webcam applications as you want with input as /dev/video2 (however you might have to tell your application the picture size, see below).

Of course, you may think resizing the scale from 320x240 to the same size is silly. Yes, it is, you can edit the source of invert.c (it suffices to remove one sign) to write a program that simply sends the stream from /dev/video0 to /dev/video1 if you prefer.

2) A more complicated example (applications using different resolutions) Do "modprobe vloopback pipes=2". Then "resize /dev/video0 /dev/video1 640x480 640x480 & resize /dev/video2 /dev/video3 640x480 320x240". (Assuming that you have only one real video device at /dev/video0. You can check with dmesg).

Now, you can watch your webcam with camstream at 640x480 (choose the device called vloopback0 output in camstream's menu, which is /dev/video2), at the sime time you can record a video of your webcam stream at 320x240 by doing "ffmpeg -vd /dev/video4 -s 320x240 picture.mpeg", you can at the same time run a webcam http server by running "camsource" (after editting camsource.conf to choose /dev/video2 or /dev/video4 as v4l_input source).

N.B. You can't use camorama with vloopback, as far as I know, camorama looks for inputs from /dev/video0. You should also not open two "view"s in the same instance of camstream. However, opening multiple instances of camsource doesn't cause a problem.

Attached Files

Attached are the recent versions of the vloopback.

Kernel 2.6

  • vloopback-1.0.tar.gz : New release with some more fixes and allow build a kernel module in debian way and fixes problems to compile in Suse. If you want to make it work with motion , use motion-3.2.6 or above. stable for kernel <= 2.6.17

Kernel 2.4

  • vloopback-0.92-snap1.tar.gz: Snaphot release for testing (this is the last version ever to be released for kernel 2.4 and is the 0.91 version with a redhat kernel 2.4.20 fix)
  • vloopback-0.91.tar.gz: Last official release for kernel 2.4. Does not build on 2.6 kernels

Installation

Note that version 1.0 is tested for kernel 2.6.8 and above . There are reports that it does not work well with older 2.6 kernels. Make sure you upgrade your kernel to 2.6.8+.

Just type make and then insmod vloopback.ko.

If you want more pipes use insmod vloopback pipes=N with N between 1 and 16.

If you want to create spare pipes use spares=N.

Type dmesg to see which video devices have been created as input and output.

For example: if you have a camera on /dev/video0 the input pipe will most likely be /dev/video1 and the output on /dev/video2.

e.g. if you want to watch an inverted image of the camera you would start invert with /dev/video0 as its input and /dev/video1 as its output.

Then start a viewing app (such as camstream or xawtv) with as input /dev/video2 and you can see yourself inverted.

Now you can load the module from anywhere with or modprobe.

Users Guide

See the video4linux loopback device API document for detailed information about the use.

FAQ

How to use effecttv with loopback ?

You have to load your webcam / capture card kernel module , i.ex :

 modprobe pwc mbufs=3 size=vga fps=15

See dmesg output to know the video device used by your device :

pwc: Registered as /dev/video0

Load vloopback device ,

modprobe vloopack

see dmseg output ( same as above )

Loopback 0 registered, input: video1,output: video2

And run effect on this way : effectv -vloopback [input vloopback device] -device [real video device]:

effectv  effectv  -vloopback /dev/video1 -device /dev/video0

I got "video_init: double buffer capturing with mmap is not supported. Video initialization failed." when i try to use my webcam with quickcam module.

You need to load this kernel module with parameter compatible=2 :

modprobe quickcam compatible=2

Comments and Bug Reports