For the complete documentation index, see llms.txt. This page is also available as Markdown.

11.3 Webcams

This section describes how to configure a camera for a FreeBSD system.

Video for Linux 2 (V4L2) is the second generation of V4L. V4L2 is the kernel driver framework for video devices in the Linux kernel.

FreeBSD requires the following tools to access and configure cameras:

Port
Description

multimedia/webcamd

A daemon ported from Linux USB webcam and DVB drivers, supporting hundreds of different USB cameras and DVB USB devices

multimedia/pwcview

Can be used to view camera video streams

multimedia/mpv

Can also be used to view camera V4L2 video streams

multimedia/v4l-utils

Used for configuring and testing Video4Linux devices

Installing Camera Software

To install the required utilities using pkg, run:

# pkg install webcamd pwcview mpv v4l-utils

Install using Ports:

# cd /usr/ports/multimedia/webcamd && make install clean
# cd /usr/ports/multimedia/pwcview && make install clean
# cd /usr/ports/multimedia/mpv && make install clean
# cd /usr/ports/multimedia/v4l-utils && make install clean

Service Management

Enable the webcamd service so it starts automatically at system boot:

Restart the device state service:

User Management

The user must belong to the webcamd group. To add user ykla to the webcamd group, run the following command:

Getting the Camera List

After installing these tools, you can use webcamd to display the list of available cameras:

The output should look similar to the following:

An available camera "Jieli-Technology-USB-Composite-Device" has been found.

Test the camera temporarily:

Keep it running in the foreground for subsequent configuration.

Device files /dev/video0 and /dev/video1 will be generated.

Viewing Camera Configuration

Use the v4l2-ctl tool to list the parameters supported by the camera:

The above output lists in detail the video formats, resolutions, and frame rates (FPS) at different resolutions supported by this camera.

Checking the Camera

Checking the Camera with multimedia/pwcview

You can use multimedia/pwcview to check whether the camera is working properly.

Temporarily disable SDL's Xv hardware acceleration to avoid unexpected situations such as a black screen. If the test passes, this environment variable can be removed.

Run pwcview again (resolution 1600x1200@30fps):

After this, multimedia/pwcview will display the camera image:

Camera Image Displayed by pwcview

Checking the Camera with mpv

You can use multimedia/mpv to check whether the camera is working properly.

The above command uses --vo=x11 to disable hardware acceleration and avoid unexpected situations. If the test passes, this parameter can be removed.

After this, multimedia/mpv will display the camera image:

Camera Image Displayed by mpv

Permanently Configuring the Camera

After confirming that the camera is working properly, you can make the above configuration permanent.

Configure the available camera by running the following command:

Note

If this is a plug-and-play USB camera, the output of webcamd -l (especially the device identifier) will change after the USB port it is connected to changes, and /etc/rc.conf may need to be updated accordingly.

You must start the webcamd service by running the following command:

The output should look similar to the following:

Testing the Camera Online

Use a "Webcam Test" website to test the camera online: https://www.onlinemictest.com/webcam-test.

Online Camera Test Display

Last updated