Skip to content

Usage and examples

hipersayanX edited this page Mar 19, 2023 · 7 revisions

Loading and unloading the driver

You must have created a proper settings file before loading the driver, otherwise the driver will not create any device. You can load the driver with:

cd akvcam/src
sudo modprobe videodev
sudo insmod akvcam.ko

and unload it with:

sudo rmmod akvcam.ko

The devices will be created as /dev/videoX where X is a number between 0 and 63, the number will be assigned automatically by V4L2 and it isn't warranted to be the same on reboot or after plugging a V4L2 compliant device.

Load on boot

To load the module on boot create a /etc/modules-load.d/akvcam.conf file and there write akvcam:

echo akvcam | sudo tee /etc/modules-load.d/akvcam.conf

And optionally, you can also set the driver parameters in /etc/modprobe.d/akvcam.conf file:

echo options akvcam key1=val1 key2=val2 | sudo tee /etc/modprobe.d/akvcam.conf

Replace keyX=valX with whatever key=value pair you want to use.

Driver parameters

This is a list of parameters you can past to the driver when inserting it with insmod.

  • loglevel (int) : Is an integer number representing a kernel log level, you can check the log messages with dmesg. Default to 0 (no messages).
  • config_file (string): The full path of the setting file to load. Default to /etc/akvcam/config.ini.

Examples

Checking compliance

You can use this command to check if the driver is ok:

v4l2-compliance -d /dev/videoX -f -s

it will return a bunch of test lines, with 0 failed and 0 warnings at the end.

Checking properties

You can check if all configured formats and emulated controls are ok with this command:

v4l2-ctl -d /dev/videoX --all

cat and echo

If you enabled rw mode in both Capture and Output device you can do this:

cat /dev/urandom > /dev/videoX

and in another terminal do:

cat /dev/videoY

where /dev/videoX is an output device, and /dev/videoY is a capture device.

Streaming with FFmpeg

You can stream a video (or any input you want) with:

ffmpeg -i video.webm -s 640x480 -r 30 -f v4l2 -vcodec rawvideo -pix_fmt rgb24 /dev/videoX

of course, the Output device must be configured to receive RGB24 640x480 30 FPS frames and must work in rw mode.

Streaming with GStreamer

gst-launch-1.0 -v videotestsrc ! video/x-raw,format=RGB ! videoconvert ! v4l2sink device=/dev/videoX

Capturing

Any capture program will work just fine, here is an example with ffplay:

ffplay /dev/videoX