I’m sure this has been described thousands of times, but today it took me again almost one hour to find out how to set up the webcam application on Linux. This HowTo was made for Debian like systems, if you are experienced enough you can easily port this HowTo onto other distros like Fedora/Redhat, Gentoo or SuSE, too.
Here we go:
-
sudo apt-get install webcam v4l-conf
- save the following content into your user’s home directory under
.webcamrc
[grab] device = /dev/video0 text = "webcam %Y-%m-%d %H:%M:%S" infofile = filename fg_red = 255 fg_green = 255 fg_blue = 255 width = 320 height = 240 delay = 3 wait = 0 input = composite1 #norm = pal rotate = 0 top = 0 left = 0 bottom = -1 right = -1 quality = 75 trigger = 0 once = 0 [ftp] host = www user = webcam pass = xxxxxx dir = public_html/images file = webcam.jpeg tmp = uploading.jpeg passive = 1 debug = 0 auto = 0 local = 1 ssh = 0
- now perform
#v4l-info | grep name name : "Camera 1" name : "Brightness" name : "Contrast" name : "Saturation" name : "Venus USB2.0 Camera"
and replace the first green line in
.webcamrc
( input = composite1) with the result you’ve got in this step “Camera 1”. Your cam will likely be called differently. Your line in .webcamrc should now look like this: - Starting
webcam
:webcam > /dev/null 2>&1 &
webcam is a simple program, you don’t have any switches and you have to care your self for an automatic launch at system start.
- Stoping
webcam
is done by kill.killall webcam
input = Camera 1
You don’t need quotes for the spaces in order to escape special characters.
Troubleshooting:
- Problem:
# webcam reading config file: /root/.webcamrc invalid input: composite1 # (or spca533, spca5xx, ZC301-2, uvcvideo )
Solution: does v4l-info really returns “composite1” as camera name for you? Replace the name you’ve got from v4l-info with the input name composite1
- Problem:
# webcam reading config file: /root/.webcamrc invalid norm: pal
Solution: uncomment the line “norm = pal”, it’s also working without it here.
- Problem:
tuner ioctl VIDIOCGTUNER: Invalid argument audio ioctl VIDIOCGTUNER: Invalid argument
Solution: I don’t have any solution for it, it’s working for me, even these errors occur.
- Problem:
The picture wasn’t uploaded onto the remote machine.
Solution: make sure in your.webcamrc
these values are set correctly if you try to use ssh.local = 0 ssh = 1
Go through all your steps manually. Did you inserted on the target machine (where the picture should be send to) your
id_dsa.pub
orid_rsa.pub
into~/.ssh/authorized_keys2
for a passwordless connection? Use ‘ssh-keygen -t dsa
‘, if you didn’t before.
Don’t use ftp, it’s very unsafe.
Thanks for taking the time to write down your experiences. I’d like to add a little, if I may.
First of all, v4l-info only reports on /dev/video0 – so if you have more than 1 video device: such as a DVB card, that’s what it will report. You need to run v4l-info /dev/video1 …. to report on a second device (plus, of course, you need to know which device you USB camera comes up as – and this can change across reboots grrrr.)
Next, the v4l-info reports multiple “name”s which one is the one that webcam expects is pretty much trial and error. In my case I was using a Philips 645 Vesta camera (one of the few that has anything like acceptable linux support). Here the value I needed for “name” turned out to be “usb”.
@pete
Excellent comment. Thanks a lot.
This will surely help people. I just remember how much of struggle it was for me.
Regards,
Andreas
I’ve got it working as well, using usb as input.
But i receive these errors every few seconds:
open filename: No such file or directory
I think i has something to do with the ‘tmp’ file, because i can’t find it anywhere.
Also, my image is loaded with noise.. I know when i used my webcam to videochat, i could adjust the FPS and the lightness and stuff, which made it a heck of a lot clearer. But as this system is using images it works a little different i think.
Hm, yes – I’ve noticed that also.
I don’t have a real good solution for it, so you might help us, if you find anything helpful.
I use the old (and ugly 😉 application xawtv.
You can install it via
apt-get pia xawtv xawtv-plugins
start it from command line (you need a DISPLAY).
Then right-click into the video window. Now you see a bunch of settings you can screw with.
The problem is, I don’t know how to make these settings permanent.
Any ideas?
Regards,
Andreas
strace shows the file it is trying to open is called “filename” because of this line in the .webcamrc file:
infofile = filename
I commented that line out and the messages went away. Not sure what info this file is supposed to provide.
infofile is meant to direct webcam to the file which contains the info to show on top of the image.
So it basicaly it provides webcam with the same info as “text = ” does.
Thanx, very helpfull hints …
… but i got another problem:
xawtv (Picture) and Camstreams (Picture & Upload) are working fine. Unfortunatly camstreams sometimes stops uploading after a while.
Any ideas (sorry, i have to use ftp, ssh & locale are already commented out. passive is set to 0, as in camstreams)?
@jo
the only hint I can give atm, is to try the ftp connection manually with same user like webcam user, and see if that works.
Another point is the availability of the image. You should get the same error, if the image from your cam is not there, or not there yet for being uploaded by your ftp client. If your [grab] and [ftp] section in your .webcamrc is swapped, try it the other way round.
And if the error occurs, is you /dev/video0 still available? Dies your cam maybe?
If all fails, try to give Google a chance by searching for “ftp: connect failed, sleeping 5 sec”, but I guess you did it already anyway.
Regards,
Andreas
I faced the same ftp problem. Fixed by set auto=1 then create a ~/.netrc file
machine http://ftp.host.com
login xxxx
password xxxx
Login informations must remain in the .webcamrc file
Then it should work
++
@mimi
Thanks!
“Camera 1?, it’s so easy, your hint to ask “v4l-info” made my day!
Thank you!
Bloggers save the world!
I made it work only by commenting out the “input” line…
Hi, i got a question, if i want upload my cam with SSH with an other port, do you know how to do it ?
Hi, i tried any kind of configuration, but it keeps telling me “can’t get rgb24 data”.
I’ve tried add, remove, edit and comment the norm= parameter. but with no luck.
Any idea?
thank you.
Hi, I successfully set up my webcam following these instructions yesterday, but I had an issue with the white balance. Somehow I fixed it yesterday but have no idea what I did. This morning I’ve got the same problem, the picture is just white. If I use Cheese the camera is working fine, can you advise me on how I can control the white balance?
Thanks,
Well, once again it has miraculously started working properly! I still have no idea what I did to make it work though… all I’ve done is open Cheese & capture an image.
Is there a way to use more then one webcam?
If so, how would the conf-file be altered?