In Linux, various USB camera interfaces exist, each with its own kernel driver family. UVC (USB Video Class) with its driver uvcvideo is a modern one that is supported by most software. Other cameras require other drivers and might have difficulties to work with modern camera software.
Webcams require a kernel driver and if available files like /dev/video0 pop up. Check what drivers got loaded lsmod.
v4l2-ctl --list-devices will show the attached cameras and its /dev/video files<n>
Does it make sense to setup an old camera with 640*480 resolution? Modern cameras are cheap have much higher resolution and the desired software interface.
The Quickcam 3000 uses the kernel module pwc and might therefore not be supported anymore by modern software written for UVC cameras.
The built-in microphone is enabled by selecting in the kernel USB Audio support.
Additionally there is setpwc user space package for it.
lsusb shows its id 0c45:6028 and this gives
c45:6028 Microdia Typhoon Easycam USB 330K (older)
to work the kernel needs to be compiled having the drivers gspca_sonixb and also the main driver gspca_main and might therefore not be supported anymore by modern software written for UVC cameras.
emerge -av media-video/v4l2loopback get the loopback driver
modprobe v4l2loopback devices=1 video_nr=10 card_label="Virtual UVC Camera" load the driver and create /dev/video10
ffmpeg -f v4l2 -i /dev/video0 -f v4l2 /dev/video10 read the none UVC camera /dev/video0 and feed it into the virtual UVC camera /dev/video10
USB cameras require lot of processing in the camera and are also less flexible and support less feature than required and possible.
libcamera moves this software and processing to the user space. It sill communicated using (but many) /dev/video<x> files but has its own API for the user space application.
Test it with (put the camera into light, otherwise debug for no reason could happen):
qv4l2 it is a gui tool that might be already installed
guvcview or guvcview -d /dev/video<n>
mplayer tv:// -tv driver=v4l2:device=/dev/video0
mplayer tv:// -tv driver=v4l2:width=352:height=288:device=/dev/video0
and mplayer can take even screen-shots pressing key s with
mplayer tv:// -tv driver=v4l2:width=352:height=288:device=/dev/video0 -vf screenshot
cheese a gui tool from gnome
xawtv -c /dev/video0 is the classic video application but more dedicated for TV cards.
The sensor chips of web cams would support usually IR and would therefore suitable to view and record pictures in the dark when having IR illumination. However the cameras have a IR filter that blocks IR and therefore the cameras can not be used in dark environment. On some cameras the IR filter can be removed, others have a support move it in and out (makes a click sound) and others are sold without IR filter. An other problem is that the focus for IR is different than from visible light, so the position of the lenses need to be adjusted.
motion is a camera surveillance application https://motion-project.github.io/.
Check if the camera works (install cheese)
Then install motion.
Edit /etc/motion/motion.conf
comments use ; and indicates how a configuration line could look like.
motion supports more than one camera so it is modular to to have a configuration file as camera-fontastic.conf and therefore settings per camera. Add full path information to the camera file in motion.conf
and comment out camera_dir.
; camera_dir camera /etc/motion/camera-fontastic.conf
When having more than one camera it should be noted the motion.conf hold the default values that are valid for all cameras, except a camera.conf file overwrites it. One overwrite for the second camera is therefore:
video_device /dev/video1
However /dev/video1 will become /dev/video0 when the first camera disappears. So it is better to use the hardware path: ls -l /dev/v4l/by-path/ and then
video_device /dev/v4l/by-path/platform-xhci-hcd.0-usb-0:1:1.0-video-index0
Alternatives when not having two identical cameras using the camera identifier instead ls -l /dev/v4l/by-id/ or set up a udev rule
sudo systemctl start motion
sudo systemctl stop motion
sudo systemctl restart motion
sudo systemctl status motion
sudo systemctl show motion
The link http://localhost:8080 should show the live stream from the camera
To have it accessible by other hosts (especially when motion runs on a headless system)
webcontrol_localhost off stream_localhost off
log goes to /var/log/motion/motion.log. The log_level can be adjusted to get the desired amount of log messages.
Captured streams and pictures are found per default in /var/lib/motion
To turn off capturing movies might as when the camera is just used for time-lapse
movie_output off
stream_localhost off threshold holds the pixel number that needs to be changed. It can be commented and replaced by threshold_tune on
A masks can be used to filters picture areas used for event detection. The area_detect splits the picture in nine rectangles 123456789 top left to bottom right.
area_detect 124578
would block events from the right columns.
mask_file <filename>.pgm
uses a pgm black and white file of the same size as the camera. black areas are ignored and white areas are detected.
Create snapshots by putting the following into the camera.conf file. The snapshot files get a timestamp in their names:
snapshot_interval 3600 snapshot_filename snapshot-%Y%m%d%H%M
Then convert the snapshots into a movie
ffmpeg -framerate 10 -i snapshot-%*.jpg output.mp4
The web control is the gui user interface at http://<IP>:8080/.
It has a menu with an Action item. Pause stops the surveillance and start starts it. Unfortunately there is no feedback so the status can not be confirmed directly:
Test if a movie occurs when moving something in front of the camera ls /var/lb/motion.
Check the log cat /var/log/motion/motion.log it will show if a movie got recorded.
However the log will not show if surveillance is paused or started. Therefore set in /etc/motion/motion.conf the log level to DBG:
# Level of log messages [1..9] (EMG, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). log_level 8
Debug messages are logged to see when pause
[0:cn0] [DBG] [STR] [Mar 28 19:54:42] webu_parseurl: Sent url: /00000/detection/pause [0:cn0] [DBG] [STR] [Mar 28 19:54:42] webu_parseurl: Decoded url: /00000/detection/pause [0:cn0] [DBG] [STR] [Mar 28 19:54:42] webu_parseurl: camid: >00000< cmd1: >detection< cmd2: >pause< parm1:>< val1:>< parm2:>< val2:><
Debug messages are logged to see when start
[0:cn0] [DBG] [STR] [Mar 28 19:54:47] webu_parseurl: Sent url: /00000/detection/start [0:cn0] [DBG] [STR] [Mar 28 19:54:47] webu_parseurl: Decoded url: /00000/detection/start [0:cn0] [DBG] [STR] [Mar 28 19:54:47] webu_parseurl: camid: >00000< cmd1: >detection< cmd2: >start< parm1:>< val1:>< parm2:>< val2:><