Video for Linux Two

February 16, 1999 - Bill Dirks ( bill.dirks@rendition.com )

Myself and others are of the opinion that Linux would benefit from an overhauled Video for Linux API made to be more flexible and extensible, and to support more kinds of devices. The existing API needs to keep shipping with Linux to maintain compatibility. Therefore I have created a new API, which I call Video for Linux Two (or "V4L2" for short). A user wishing to use the new API installs the Video for Linux Two files, which replace the corresponding files for the original API. V4L2 is a thorough overhaul and not backward compatible with the original API, so drivers and applications already written for Video for Linux will have to be ported to work with V4L2.

On this page you will find general information about V4L2, and V4L2 resources, including documentation and source code, and links to drivers and applications that have been written for or ported to V4L2.

libv4l2. The existing V4L2 specifications are for the device driver interface. We are now working on a user-mode function library to act as a layer between application code and the device drivers, to make writing applications to V4L2 easier. When it is ready, all V4L2 functionality will be available through the library, so it will not be necessary for applications to make any driver calls directly. The library is still in the design stages. I'll have more information later.

People & Projects [ http:/millennium.diads.com/bdirks/peopleprojects.htm ] page. This is a list of people who are contributing to V4L2 or doing V4L2-related work, and the projects they are working on. These include specifications, drivers, libraries, and applications.

V4L2 requires Linux kernel 2.2.x (or a late 2.1.x kernel).


Resources

These are the kernel device driver API specifications. The Driver Writer's Guide documents the V4L2 kernel-mode API functions, and provides additional information regarding how to write V4L2 drivers.

Video for Linux Two Documentation
Video for Linux Two Devices [ http:/millennium.diads.com/bdirks/v4l2dev.htm ] 1999-01-27
Video Capture API Specification [ http:/millennium.diads.com/bdirks/v4l2cap.htm ] 1999-01-27
Codec API Specification [ http:/millennium.diads.com/bdirks/v4l2cod.htm ] 1999-01-27
Effects API Specification [ http:/millennium.diads.com/bdirks/v4l2fx.htm ] 1999-01-27
Video Output Device API Specification [ http:/millennium.diads.com/bdirks/v4l2out.htm ] 1999-01-27
Driver Writer's Guide [ http:/millennium.diads.com/bdirks/v4l2dwg.htm ] 1999-01-27
Standard Image Formats [ http:/millennium.diads.com/bdirks/v4l2fmt.htm ] 1998-11-27

Source Code

For instructions on installing V4L2 see the readme file in the V4L2 source archive. You will need to configure your kernel to include Video for Linux as a module, but disable all the v4l drivers since they will not compile after the original v4l header file has been replaced with the new header file.

The v4l2samp.tgz file includes a sample device drivers which use no hardware, so you can start writing or porting applications to V4L2 even if you don't have V4L2-supported hardware yet. So far video capture and video output sample drivers are included. More information is in the readme file included in the archive.

There is now a sample capture program, xcaptest.c, which exercises the capture functions of a V4L2 driver. And a video control panel program, vidpanel.c, that exercises the brightness, contrast, etc. controls on a V4L2 device. These work with the sample capture driver. These are in the apps.tgz file. The vcat and vctrl programs are for use from the command line or a shell script, and are for capturing frames, and setting device parameters.

Video for Linux Two Source Code
V4L2 source code: videodev.c & videodev.h files. Unpack in /usr/src/linux. videodev19990207.tgz [ http:/millennium.diads.com/bdirks/videodev19990207.tgz ] 1999-02-07 (13KB)
Previous V4L2 sources videodev19990127.tgz [ http:/millennium.diads.com/bdirks/videodev19980127.tgz ] 1999-01-27 (13KB)
Previous V4L2 sources videodev19990122.tgz [ http:/millennium.diads.com/bdirks/videodev19990122.tgz ] 1999-01-22 (31KB)
Sample applications (xcaptest, vidpanel, vcat, vctrl). Includes a Makefile apps19990216.tgz [ http:/millennium.diads.com/bdirks/apps19990216.tgz ] 1999-02-16 (8KB)
Sample drivers (v4l2cap.c, v4l2out.c) v4l2samp19990207.tgz [ http:/millennium.diads.com/bdirks/v4l2samp19990207.tgz ] 1999-02-07 (31KB)
Changes log [ http:/millennium.diads.com/bdirks/videodev.txt ]

When you unpack videodev*.tgz in /usr/src/linux, it will overwrite include/linux/videodev.h and drivers/char/videodev.c.

Videodev.c and videodev.h are covered by the GPL. The sample code including v4l2cap, xcaptest, and vidpanel are public domain and have no copying or derived-work restrictions of any kind.


V4L2 Drivers and Applications
Drivers for the Winnov Videum [ http:/millennium.diads.com/bdirks/winnov.htm ] series of capture cards
Erik Walthinsen's Omega V4L2 site [ http:/www.cse.ogi.edu/~omega/v4l2/ ]: Bt848 driver; Color QuickCam driver; AIMSlab RadioTrack driver; tools...
Gerd Knorr's xawtv TV application [ http:/www.in-berlin.de/User/kraxel/xawtv.html ]
...for more stuff see the People & Projects [ http:/millennium.diads.com/bdirks/peopleprojects.htm ] page


If you would like to contribute to the V4L2 project, send me an email.

If you have suggestions or patches for V4L2 source code send them to me at bill.dirks@rendition.com, or the V4L mail list at video4linux-list@redhat.com . I would ask that you please send patches as (gzip'ed) attachments because it has been my experience that 'patch' almost always rejects patches emailed in the body of a letter due to either tabs converted to spaces or wrapping of long lines.


Commercial Applications and Deployment

I would say that V4L2 is not at the stage yet where it should be used in a commercial product. The user function library is still under construction. The device driver specifications have settled down, but there will probably be a few minor changes as the library API is designed. Now that the 2.2 kernel is out, I will try to make the library available soon. Driver development can certainly proceed now. Application projects can be begun using the driver API directly for now, and porting to the function library later, which will be easy since it is a simplification.

V4L2 is already suitable for experimentation, development and testing. Anyone interested in using V4L2 devices and drivers can begin working on that now, so we can make sure the specifications and drivers meet your needs.


As time goes on I plan to extend the scope of V4L2 to include:

  1. Video tape recorder control driver specification.
  2. User-mode libraries to make writing V4L2 application easier. (begun)
  3. A specification for user-mode software codecs and video effects modules.
  4. A file format specification for saving captured video sequences.
  5. Libaries/applications for writing and playing video sequence files. (There may be existing stuff we can use.)
I also want to make a nice developer kit to ease development or porting of V4L2 code, and to solve the chicken-and-egg problem inherent when a new API is introduced. The kit would include:
  1. All specifications and documentation, of course.
  2. Working sample drivers that can be used for testing applications, or as a code base for new drivers. (There is a sample capture driver now.)
  3. Sample/test applications which can be used for testing drivers, or as example code for application developers.
  4. Universal video control panel application.
  5. Universal TV channel-changer application.
  6. Other tools/code that may be of use(?)

Copyright 1999 http://millennium.diads.com/bdirks/v4l2.htm