(Mini) How to set up Logitech QuickCam Pro 4000 in Linux, and
how to use Mplayer (and mencoder) with it

Last updated 2004-12-10

(This page is Not really maintained and surely looks ugly, but...)

There is a new pwc driver for the camera, which no longer need pwcx binary module, so use it rather than the old pwc+pwcx.

The instructions below are somewhat obsolete until corrected.

Logitech QuickCam Pro 4000 camera (Philips PCVC740) is equipped with: a Sony CCD sensor + Exas 98L59 (46)

How to set up the modules (videodev, pwc, pwcx): <  http://mia.ece.uic.edu/~papers/volans/quickcam.html >

In short, how to set up the modules and stuff:

Make devices (in case your kernel does not have devfs):

mkdir /dev/usb
mknod /dev/usb/mixer c 14 16
mknod /dev/usb/audio c 14 35
ln -s usb/mixer /dev/mixer2
ln -s usb/audio /dev/dsp2
mknod /dev/video0 c 81 0

Note! The minor and major numbers of those character devices you'll need to create depends what real device slots kernel assings to the USB-devices. You'll see the assigned numbers from the system log (/var/log/messages) after the pwc, and usb/audio module has been loaded.

Install the pwcx module to 2.4 kernel as: /lib/modules/usb/usb-pwcx-8.2.2/x86/gcc-3.2/pwcx-2.4.20.o
pwc module should had been installed already with your kernel.

Add following 5 lines to /etc/modules.conf

alias char-major-81 videodev
above videodev pwc
alias char-major-81-0 pwc
options pwc size=vga leds=250,250 fps=15 mbufs=2 compression=3 # power_save=1
post-install pwc /sbin/insmod --force -k /lib/modules/usb/usb-pwcx-8.2.2/x86/gcc-3.2/pwcx-2.4.20.o >/dev/null 2>&1  || :

For Fedora 2, kernel 2.6.8-1.521, you could try the binary rpm I made for myself: < kernel-module-pwcx-2.6.8-1.521-9.0-0.beta2.fr.i386.rpm>
Source rpm for above: <http://ftp.freshrpms.net/pub/freshrpms/fedora/linux/testing/2/kernel-modules/kernel-module-pwcx-9.0-0.beta2.fr/>

Hotplug support: add following 2 lines to /etc/hotplug/usb.usermap

QuickCam4000audio   0x0003      0x058f    0x9254    0x0000       0x0000       0x00         0x00            0x00            0x00            0x00               0x00               0x00000000
QuickCam4000        0x0003       0x046d    0x08b2   0x0000       0x0000       0x00         0x00            0x00            0x00            0x00               0x00               0x00000000

Add this shell-script to as /etc/hotplug/usb/QuickCam4000 and give execution permission to it (chmod u+x QuickCam4000):

#!/bin/sh
exec modprobe pwc

Add the following shell-script to /etc/hotplug/usb/QuickCam4000audio and give execution permissions:

#!/bin/sh
exec modprobe audio

How to use MPlayer with QuickCam 4000 Pro, my examples

How to use only Video with mplayer:
fps=15 should work with 640x480 [VGA]. (With 160x120 [QSIF] and 320x240 [SIF] one should be able to use fps=30 in the options of the driver module above. See the FAQ.)

$ mplayer -rawvideo on:fps=15:w=640:h=480 /dev/video0
To use resolution 160x120 instead of 640x480, use xawtv to set it to 160x120 and then use mplayer with "w=160:h=120". To set the pwc740 driver back to VGA-resolution state, hit 'f' in xawtv, and then 'q' to quit.

Video and audio:
Information from the system log (usb/audio.o module)

usbaudio: device 2 interface 2 altsetting 1: format 0x00000010 sratelo 44100 sratehi 44100 attributes 0x00
usbaudio: device 2 interface 2 altsetting 2: format 0x00000010 sratelo 22050 sratehi 22050 attributes 0x00
usbaudio: device 2 interface 2 altsetting 3: format 0x00000010 sratelo 11025 sratehi 11025 attributes 0x00
usbaudio: device 2 interface 2 altsetting 4: format 0x00000010 sratelo 8000 sratehi 8000 attributes 0x00
usbaudio: registered dsp 14,35
usbaudio: registered mixer 14,16

So the camera should support one single 8bit channel with 8000, 11025, 22060, 44100 samplerates. Haven't got other rates but 8000 to work yet:

$ mplayer -audiofile /dev/dsp2 -audio-demuxer 20 -rawaudio on:channels=1:samplesize=1:rate=8000 -rawvideo on:fps=15:w=640:h=480 /dev/video0

To encode input (basic simple) to MPEG4 with mencoder:

$ mencoder -audiofile /dev/dsp2 -audio-demuxer 20 -rawaudio on:channels=1:samplesize=1:rate=8000 -rawvideo on:fps=10:w=640:h=480 /dev/video0 -ovc lavc -ofps 10 -oac mp3lame -o QuickCam4000_basic.avi 

To encode input (fast, poor quality) to MPEG4 with mencoder:

$ mencoder -audiofile /dev/dsp2 -audio-demuxer 20 -rawaudio on:channels=1:samplesize=1:rate=8000 -rawvideo on:fps=10:w=640:h=480 /dev/video0 -ovc lavc -lavcopts vbitrate=2 -ofps 10 -oac mp3lame -lameopts vbr=2:aq=0:mode=3:aq=9 -o QuickCam4000_pq.avi 

To encode with MPEG4 with all kind of (cpu-usage heavy) quality optimizations:

$ mencoder -audiofile /dev/dsp2 -audio-demuxer 20 -rawaudio on:channels=1:samplesize=1:rate=8000 -rawvideo on:fps=10:w=640:h=480 /dev/video0 -ovc lavc -lavcopts vcodec=mpeg4:vhq:v4mv:vqscale=3:keyint=100:vb_strategy=1:trell -ofps 10 -oac mp3lame -lameopts vbr=2:mode=3:q=0:aq=0 -o QuickCam4000_hq.avi 

Best this far for me:

$ time mencoder -audiofile /dev/dsp2 -audio-demuxer 20 -rawaudio on:channels=1:samplesize=1:rate=8000 -rawvideo on:fps=10:w=640:h=480 /dev/video0 -ovc lavc -lavcopts vcodec=mpeg4:vhq:keyint=300:vbitrate=500:vb_strategy=1 -ofps 15 -oac mp3lame -lameopts abr:mode=3:br=12 -o QuickCam4000.avi
vbitrate=200:v4mv or even 100 works also pretty well if the scene is mostly unchanging. With vbitrate=300:v4mv there was 50% lost frames seen from the system log.

One way to record also would be to just copy the video first in the real time with '-ovc copy' and then later compress the video with max quality, min size settings. This obviously would take 10 fps * 640 * 480 * 3 = 9216 kB/s. ~= 31 GiB/h.

For survey use, motion is better than mplayer alone.


(c) Jouni döt Lohikoski ät iki d0t fi