mount
it with the card plugged in and view the .mov (?) files through multimedia/vlc.ffmpeg-all
(1) manual page – It is very extensive (nearly 30k lines!) and contains lots of examples. pwcsnap
that supports motion detection. However, it only writes single images (snapshots) to the disk, not video streams (and no audio). The port requires X11 for building because of the included pwcview program, but the pwcsnap utility is CLI-only./dev/video0All right, thank you guys for suggestions, but I'm still not sure where I should point mencoder and/or ffmpeg to record the video. What should be the name of the device?
Read the documentation.How do I call it in those programs?
CUSE is a library that allows drivers for character devices to run in userland, so they don't have to run inside the kernel. (Just like FUSE allows filesystem drivers to run in userland.)How would I know that the webcam is indeed detected by the driver? I have C310 and did cuse_load="YES" in loader.conf, but still not sure. I get uaudio entries in messages, but that's about that.
Also, what is the purpose of CUSE and webcamd? Each of those does what exactly?
webcamd
that runs on top of CUSE. When you load it, it will print messages indicating whether it found your webcam. Also, it will create the /dev/video0 device node.I've built it with options CUSE, WEBCAM and HAL enabled (but I'm not sure if HAL is really necessary). Make sure that the CUSE kernel module is loaded (typeShould I build it with HAL and DBUS support for C310 to work? Right now I've built it with only "CUSE" and "WEBCAM" flags set. C310 isn't detected as far as I can see. I don't want to enable every option (or use the default set) there because it takes in a lot of dependencies I may not need.
kldstat
to check). Add a line webcamd_enable="yes"
to /etc/rc.conf.# 0x046d / 0x0819 = Logitech C210
# 0x046d / 0x081b = Logitech C310
attach 100 {
match "vendor" "0x046d";
match "product" "0x081[9b]";
action "/usr/local/etc/rc.d/webcamd start $cdev";
};
service devd restart
webcamd
process starts automatically and creates /dev/video0. You can then use mplayer, for example, to test if the webcam works:mplayer -tv driver=v4l2 tv://
-tv
, for example:mplayer -tv driver=v4l2:width=1280:height=960 tv://
webcamd -l
.Please refer to the ffmpeg documentation, especially the manual page ffmpeg-all(1). It answers all of those questions. In particular, the webcam resolution can be changed with theI managed to get webcamd working, two questions, however:
1. When I do a very simple ffmpeg -i /dev/video0 it tells me that device/input resolution is 640x480. How can I get it to operate in 1280x720 mode? The video itself records fine, but the resolution is not at maximum.
2. How do I provide ffmpeg with audio source from the same camera? Messages log tells me that there are several devices at play, uaudioX and mixerZ amongst them. I can only see mixerZ in /dev, no pcm or uaudio entries. Mixer command sees the USB audio device just fine. So I'd like to know what device node I can use to capture audio and how to feed both the video and audio stream to ffmpeg in a single command.
-video_size
option. For audio recording the device /dev/dsp is used (unless you use ALSA or some other framework). There is even an example in the manual page for recording audio + video at the same time; it's actually quite simple. Note that /dev/dsp might be a symlink that points to the actual sound device. Type cat /dev/sndstat
to see the list of available sound devices – if one of them is record-only (no playback), then that's probably your webcam's microphone. With sysctl hw.snd.verbose
you can control the verbosity of /dev/sndstat; see the sound(4) manual page for details.Input #0, video4linux2, v4l2, from '/dev/video0':
Duration: N/A, start: 1568315158.632417, bitrate: 147456 jb/s
Stream #0:0: Video: rawvideo (YUV2 / 0x32595559), yuyv422, 640x480, 147456 kb/s, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
Installed devices:
pcm0: <ATI R6xx (HDMI)> (play)
pcm1: <ATI R6xx (HDMI)> (play)
pcm2: <ATI R6xx (HDMI)> (play)
pcm3: <ATI R6xx (HDMI)> (play)
pcm4: <ATI R6xx (HDMI)> (play)
pcm5: <ATI R6xx (HDMI)> (play)
pcm6: <Realtek ALC1220 (Rear Analog 5.1/2.0)> (play/rec) default
pcm7: <Realtek ALC1220 (Front Analog)> (play/rec)
pcm8: <Realtek ALC1220 (Rear Digital)> (play)
pcm9: <USB audio> (rec)
pcm10: <USB audio> (play/rec)
No devices installed from userspace.
uaudio1 on uhub0
uaudio1: <vendor 0x046d product 0x081b, class 239/2, rev 2.00/0.12, addr 1> on usbus0
uaudio1: No playback.
uaudio1: Record: 48000 Hz, 1 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Record: 32000 Hz, 1 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Record: 24000 Hz, 1 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Record: 16000 Hz, 1 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: No MIDI sequencer.
pcm9: <USB audio> on uaudio1
uaudio1: No HID volume keys found.
/dev
/dev/log
/dev/reroot
/dev/reroot/reroot
/dev/cuse
/dev/console
/dev/sndstat
/dev/random
/dev/urandom
/dev/devctl
/dev/devctl2
/dev/geom.ctl
/dev/mdctl
/dev/input
/dev/input/event0
/dev/input/event1
/dev/input/event2
/dev/input/event3
/dev/input/event4
/dev/input/event5
/dev/kbdmux0
/dev/kbd1
/dev/mem
/dev/kmem
/dev/netmap
/dev/full
/dev/null
/dev/zero
/dev/pci
/dev/fd
/dev/fd/0
/dev/fd/1
/dev/fd/2
/dev/stdin
/dev/stdout
/dev/stderr
/dev/nfslock
/dev/auditpipe
/dev/audit
/dev/midistat
/dev/sequencer0
/dev/music0
/dev/tcp_log
/dev/io
/dev/klog
/dev/uinput
/dev/ctty
/dev/consolectl
/dev/sysmouse
/dev/fido
/dev/bpf
/dev/bpf0
/dev/efi
/dev/acpi
/dev/apmctl
/dev/apm
/dev/hpet0
/dev/usb
/dev/usb/0.1.0
/dev/usb/1.1.0
/dev/usb/0.1.1
/dev/usb/1.1.1
/dev/usb/1.2.0
/dev/usb/1.2.1
/dev/usb/1.2.2
/dev/usb/1.2.3
/dev/usb/1.2.4
/dev/usb/1.2.5
/dev/usb/1.3.0
/dev/usb/0.2.0
/dev/usb/1.3.1
/dev/usb/0.2.1
/dev/usb/0.2.6
/dev/usb/0.2.7
/dev/usb/0.3.0
/dev/usb/0.3.1
/dev/usb/0.3.2
/dev/usb/0.3.3
/dev/usb/0.3.4
/dev/usb/1.4.0
/dev/usb/1.4.1
/dev/usb/1.4.2
/dev/usb/1.5.0
/dev/usb/1.5.1
/dev/usb/1.5.2
/dev/usb/1.5.3
/dev/usb/1.5.4
/dev/ugen0.1
/dev/ugen1.1
/dev/ttyu2
/dev/ttyu2.init
/dev/ttyu2.lock
/dev/cuau2
/dev/cuau2.init
/dev/cuau2.lock
/dev/ttyu3
/dev/ttyu3.init
/dev/ttyu3.lock
/dev/cuau3
/dev/cuau3.init
/dev/cuau3.lock
/dev/ttyu4
/dev/ttyu4.init
/dev/ttyu4.lock
/dev/cuau4
/dev/cuau4.init
/dev/cuau4.lock
/dev/ttyu5
/dev/ttyu5.init
/dev/ttyu5.lock
/dev/cuau5
/dev/cuau5.init
/dev/cuau5.lock
/dev/atkbd0
/dev/kbd0
/dev/ufssuspend
/dev/zfs
/dev/netdump
/dev/usbctl
/dev/xpt0
/dev/mixer0
/dev/mixer1
/dev/mixer2
/dev/mixer3
/dev/mixer4
/dev/mixer5
/dev/mixer6
/dev/mixer7
/dev/mixer8
/dev/devstat
/dev/ada0
/dev/ada0p1
/dev/ada0p2
/dev/pass0
/dev/pass1
/dev/pass2
/dev/pass3
/dev/ttyv0
/dev/ttyv1
/dev/ttyv2
/dev/ttyv3
/dev/ttyv4
/dev/ttyv5
/dev/ttyv6
/dev/ttyv7
/dev/ttyv8
/dev/ttyv9
/dev/ttyva
/dev/ttyvb
/dev/ada1
/dev/gpt
/dev/gpt/EFI%20System%20Partition
/dev/gpt/efiboot0
/dev/gpt/swap0
/dev/gpt/Titan
/dev/msdosfs
/dev/msdosfs/EFI
/dev/msdosfs/EFISYS
/dev/ada1p1
/dev/ada1p2
/dev/ada1p3
/dev/ada2
/dev/ada3
/dev/ada2p1
/dev/ada2p2
/dev/ada3p1
/dev/ada3p2
/dev/ugen1.2
/dev/ugen1.3
/dev/ugen0.2
/dev/ugen0.3
/dev/ugen1.4
/dev/ukbd0
/dev/kbd2
/dev/ugen1.5
/dev/ukbd1
/dev/kbd3
/dev/mixer9
/dev/umidi0.0
/dev/mixer10
/dev/uhid0
/dev/uhid1
/dev/uhid2
/dev/ums0
/dev/video0
/dev/video1
Works fine for me. Would you please show the ffmpeg command that you used, exactly? I suspect maybe the order of options is wrong. Options that apply to a certain input must precede that input on the command line. The following command works fine for me and records 10 seconds of video at 1280×720:Firstly, -video_size option doesn't seem to change the raw size of the stream. I.e. it appears the camera itself is operating in 640x480 mode by default and there's nothing ffmpeg can do about that
ffmpeg -f video4linux2 -video_size hd720 -t 10 -i /dev/video0 test.mkv
...
Input #0, video4linux2,v4l2, from '/dev/video0':
Duration: N/A, start: 1568548982.942126, bitrate: 147456 kb/s
Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 1280x720, 147456 kb/s, 10 fps, 10 tbr, 1000k tbn, 1000k tbc
As I said before, the devices are named /dev/dsp*, not /dev/pcm. Also, they are created on demand when they are opened by an application that uses the OSS interface, so you don't see them listed when you just doSecond, I cannot find any /dev/pcm entries in my /dev tree.
ls /dev
without running an audio application. cat /dev/sndstat
looks like this (with sysctl hw.snd.verbose=0
which is the default):pcm0: <NVIDIA (0x0081) (HDMI/DP 8ch)> (play)
pcm1: <NVIDIA (0x0081) (HDMI/DP 8ch)> (play)
pcm2: <Realtek ALC1220 (Analog 5.1+HP/2.0)> (play/rec) default
pcm3: <Realtek ALC1220 (Rear Digital)> (play)
pcm4: <Realtek ALC1220 (Front Analog Mic)> (rec)
pcm5: <USB audio> (rec)
pcm5
, so the corresponding base device would be /dev/dsp5. See the sound(4) manual page for more information; it explains how all of that fits together.AUDIODRIVER=oss AUDIODEV=/dev/dsp5 sox -d test.wav trim 0 10
Well, ffmpeg doesn't guess anything. It just takes what the camera delivers (via the V4L2 API). Obviously, by default the camera delivers a 480p stream. When you use theYes the order of options was wrong when I tried it, the moment I put video_size before the input, it started recording in the correct resolution. So that part is solved, even though I cannot understand the exact process involved in turning 720p images into 640x480 and vice versa. I.e. if we suppose that the raw stream *is* actually 720p then why would ffmpeg "guess" that it's 640x480? And similarly, how can it just take 720p stream and dump 640x480 stream out of it without processing.
-video_size
option, ffmpeg uses a V4L2 function to send a command to the camera to change the resolution of the stream that the camera sends.Please useframe rate is not the camera's maximal and hovers around 5-6 fps. I know it can record 25fps perfectly fine. However just putting -r 25 before the -i doesn't make it switch to higher fps, instead I get the final video that runs too fast - simply making those 5 fps go like 25 fps.
-framerate
, not -r
. The difference is explained in the manual page.I'm sorry, I haven't tried recording audio from the webcam with ffmpeg yet. When using sox(1), it works out of the box, without having to specify anything (except for the device, of course). I think it reports the audio as 48 kHz 16bit signed PCM.I also cannot guess the correct audio format that the camera provides. Do you happen to know what it is? ffmpeg -formats gives out a lot of audio formats. I've tried a couple of PCM formats, 8 bit signed and 16 bit signed LE, both are not the correct ones for the camera - I do get the output but it's noise.