Welcome to Linux Knowledge Base and Tutorial
"The place where you learn linux"
Let The Music Play: Join EFF Today

 Create an AccountHome | Submit News | Your Account  

Tutorial Menu
Linux Tutorial Home
Table of Contents

· Introduction to Operating Systems
· Linux Basics
· Working with the System
· Shells and Utilities
· Editing Files
· Basic Administration
· The Operating System
· The X Windowing System
· The Computer Itself
· Networking
· System Monitoring
· Solving Problems
· Security
· Installing and Upgrading
· Linux and Windows

Glossary
MoreInfo
Man Pages
Linux Topics
Test Your Knowledge

Site Menu
Site Map
FAQ
Copyright Info
Terms of Use
Privacy Info
Disclaimer
WorkBoard
Thanks
Donations
Advertising
Masthead / Impressum
Your Account

Communication
Feedback
Forums
Private Messages
Surveys

Features
HOWTOs
News Archive
Submit News
Topics
User Articles
Web Links

Google
Google


The Web
linux-tutorial.info

Who's Online
There are currently, 54 guest(s) and 0 member(s) that are online.

You are an Anonymous user. You can register for free by clicking here

  

HOWTO Home

Current HOWTO: Webcam-HOWTO


Accessing the Video Device

3. Accessing the Video Device

The following section applies to all connection types.

3.1. The Video Devices Node

The Linux kernel requires a virtual device node be created to access and control the device in question. It may have already been created for you at boot-up; ls -l /dev/video* (with an asterisk) or alternatively find /dev -name video* or even visual inspection of the /dev directory with your favorite file manager can give you an idea if the video devices exist. If so you can proceed to Section 3.2; if not you will need to create them manually.

An easy way to create them, if available with your Linux distribution, is use of the MAKEDEV script, which may be located in /dev or the usual places for storing executable commands (/bin,/sbin and so on). The manual page for MAKEDEV (man MAKEDEV) can guide you further, but be aware of the device-specific command options. If MAKEDEV doesn't work or doesn't exist, or you just prefer doing things the hard way, move on to the next paragraph.

A device can be created as a block (such as a drive), a fifo (file-in-file-out or pipe, as in xconsole) or a character device, which represents other hardware. Each device has a major and a minor number "coordinate" to tell the kernel what it is and where to access it. These numbers are not arbitrary. The major number 81 with minor number 0, 1, 2, and so on are by convention assigned to Video4linux devices, including TV tuner boards and webcams. In order to create the video device /dev/video0, use mknod at the command line:

   #  mknod /dev/video0 c 81 0

where c represents a character device.

You can use the following script, which I have borrowed from the kernel source (located in linux/Documentation/video4linux/bttv/MAKEDEV of the source tree):

   #!/bin/bash
   function makedev () {
	for dev in 0 1 2 3; do echo "/dev/$1$dev:
	char 81 $[ $2 + $dev ]" rm -f /dev/$1$dev
	mknod /dev/$1$dev c 81 $[ $2 + $dev ] chmod
	666 /dev/$1$dev
   	done

   	# symlink for default device
	rm -f /dev/$1 ln -s /dev/${1}0 /dev/$1
   	}

	# see http://roadrunner.swansea.uk.linux.org/v4lapi.shtml
	echo "*** new device names ***" makedev video
	0 makedev radio 64 makedev vtx 192 makedev vbi 224
	# "*** old device names (for compatibility only) ***"
	#makedev bttv 0 #makedev bttv-fm 64 #makedev bttv-vbi 224

Simply copy and paste the above into your favorite editing program, save it as MAKEDEV or whatever name you like, make it executable (i.e., chmod u+x MAKEDEV), and then execute it as root:

   #  ./MAKEDEV

3.2. Groups and Permissions

It is a good idea to be sure that your user account can access the device once all modules are loaded and device nodes created. The most security-conscious way to do that is to add access for a particular group. On my system, the members of the group 'video' are allowed to use the webcam, scanner and other photographic devices. The way to accomplish this is to first change the ownership of the devices in /dev like so (as root):

   #  chown root.video /dev/usb/video*

...where root.video are the owner and group the device will now belong to. Obviously, the specific command will vary by your system and the type of device. It is important that you change the ownership of the device node itself and not the symlink; symlinks' ownerships are affected only by changing the parent devices or files they point to.

To see if your user account is a member of the group in question, as root issue the following command: grep -e video /etc/group. You should see something like the following:

   video:x:44:

...where '44' is the group number. Since no members follow the last colon in the 'video' group, we can add them, let's say user 'jhs' with the command

   #  adduser jhs  video

After this, it's simply a matter of allowing read and write access for the user in question of the device like so:

   #  chmod g+rw /dev/v4l/video0

...where g+rw means add read and write access for group. See the documentation for chmod (man chmod or info chmod) for further info.


The Linux Tutorial completely respects the rights of authors and artists to decide for themselves if and how their works can be used, independent of any existing licenses. This means if you are the author of any document presented on this site and do no wish it to be displayed as it is on this site or do not wish it to be displayed at all, please contact us and we will do our very best to accommodate you. If we are unable to accommodate you, we will, at your request, remove your document as quickly as possible.

If you are the author of any document presented on this site and would like a share of the advertising revenue, please contact us using the standard Feedback Form.


  
Help us cut cost by not downloading the whole site!
Use of automated download sofware ("harvesters") such as wget, httrack, etc. causes the site to quickly exceed its bandwidth limitation and therefore is expressedly prohibited. For more details on this, take a look here

Login
Nickname

Password

Security Code
Security Code
Type Security Code


Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.

Help if you can!


Amazon Wish List

Did You Know?
The Linux Tutorial welcomes your suggestions and ideas.


Friends



Tell a Friend About Us

Bookmark and Share



Web site powered by PHP-Nuke

Is this information useful? At the very least you can help by spreading the word to your favorite newsgroups, mailing lists and forums.
All logos and trademarks in this site are property of their respective owner. The comments are property of their posters. Articles are the property of their respective owners. Unless otherwise stated in the body of the article, article content (C) 1994-2013 by James Mohr. All rights reserved. The stylized page/paper, as well as the terms "The Linux Tutorial", "The Linux Server Tutorial", "The Linux Knowledge Base and Tutorial" and "The place where you learn Linux" are service marks of James Mohr. All rights reserved.
The Linux Knowledge Base and Tutorial may contain links to sites on the Internet, which are owned and operated by third parties. The Linux Tutorial is not responsible for the content of any such third-party site. By viewing/utilizing this web site, you have agreed to our disclaimer, terms of use and privacy policy. Use of automated download software ("harvesters") such as wget, httrack, etc. causes the site to quickly exceed its bandwidth limitation and are therefore expressly prohibited. For more details on this, take a look here

PHP-Nuke Copyright © 2004 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.13 Seconds