Search by Tags

Webcam (Linux)

 

Compare with Revision




Subscribe for this article updates

Drivers for regular USB Video Class (UVC) Webcam devices are enabled in our pre-built images. The driver exports the webcam through the Video4Linux2 (V4L2) API. User-space video utilities such as GStreamer can be used to display or store the video stream.

For supported UVC compatible webcams have a look at www.ideasonboard.org/uvc.

[  102.903321] usb 2-1: new high speed USB device using tegra-ehci and address 2
[  103.233213] usb 2-1: New USB device found, idVendor=046d, idProduct=0805
[  103.241038] usb 2-1: New USB device strings: Mfr=0, Product=0, SerialNumber=2
[  103.248335] usb 2-1: SerialNumber: FC377070
[  103.253237] uvcvideo: Found UVC 1.00 device  (046d:0805)
[  103.297988] input: UVC Camera (046d:0805) as /devices/platform/tegra-ehci.2/usb2/2-1/2-1:1.0/input/input1

Gstreamer Video4Linux2

Installation

Our latest V2.x images for Tegra and i.MX6 based modules come with the required GStreamer Video4Linux2 source pre-installed.

On Vybrid based modules one has to install GStreamer, Video4Linux2 and some additional packages:

# opkg install gst-plugins-good-video4linux2 gst-plugins-base-ximagesink gst-plugins-base-ffmpegcolorspace gst-plugins-bad-fbdevsink

For images V2.6 and newer the GStreamer 1.x series needs to be used:

# opkg install gstreamer1.0-plugins-base-ximagesink gstreamer1.0-plugins-good-video4linux2 gstreamer1.0-plugins-base-videoconvert gstreamer1.0-plugins-bad-fbdevsink

Gstreamer Video4Linux2 piplines

Pipeline to store the unconverted raw video stream in a file:

gst-launch v4l2src device=/dev/video0 ! video/x-raw-yuv, framerate=10/1, width=320, height=240 ! filesink location=test.raw

Pipline for Tegra based modules using nvxvimagesink (accelerated)

gst-launch v4l2src device=/dev/video0 ! 'video/x-raw-yuv, framerate=30/1, width=640, height=480, format=(fourcc)YUY2' ! nvvidconv ! nvxvimagesink -v

Pipeline for i.MX6 based modules using i.MX6 optimized sink (V2.5: imxv4l2sink, V2.4 and earlier: mfw_v4lsink):

gst-launch v4l2src device=/dev/video0 ! 'video/x-raw-yuv, width=(int)640, height=(int)480, format=(fourcc)YUY2' ! imxv4l2sink disp-width=640 disp-height=480

Pipeline for Vybrid based modules using X-Server window (Software only, tested on Colibri VF61):

gst-launch v4l2src device=/dev/video0 ! 'video/x-raw-yuv,width=320,height=240,framerate=30/1' ! ffmpegcolorspace ! ximagesink

Using GStreamer 1.x series

# gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/x-raw,width=320,height=240,framerate=30/1' ! videoconvert ! ximagesink

Pipeline for Vybrid based modules using framebuffer (fbdev) sink (Software only, tested on Colibri VF61):

gst-launch v4l2src device=/dev/video0 ! 'video/x-raw-yuv,width=640,height=480,framerate=15/1' ! ffmpegcolorspace ! fbdevsink

Using GStreamer 1.x series

# gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/x-raw,width=640,height=480,framerate=15/1' ! videoconvert ! fbdevsink

This pipeline is using the CPU to convert color space and composite the video. However, on Colibri VF61, VGA (640x480) with up to 15 frames per second has been tested successfully (~80% CPU load).

Note: The format capabilities of a UVC Webcam can be displayed using v4l2-ctl:

v4l2-ctl --list-formats-ext

Troubleshooting

uvcvideo: Failed to submit URB 0 (-28) / system error: No space left on device

If you get the following error when trying to concurrently stream video from multiple USB cameras you may have run out of available USB bandwidth. Try connecting your cameras to independent USB host controllers:

root@colibri-t30:~# gst-launch v4l2src device=/dev/video1 ! 'video/x-raw-yuv, framerate=30/1, width=640, height=480, format=(fourcc)YUY2' ! nvvidconv ! nvxvimagesink -v
Setting pipeline to PAUSED ...
[ 1762.593772] uvcvideo: Failed to submit URB 0 (-28).
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Error starting streaming on device '/dev/video1'.
Additional debug info:
/build/linuxdev/oe-core_V2.6.1/build/tmp-glibc/work/armv7at2hf-vfp-neon-angstrom-linux-gnueabi/gst-plugins-good/0.10.31-r8/gst-plugins-good-0.10.31/sys/v4l2/gstv4l2object.c(2230): gst_v4l2_object_start_streaming (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
system error: No space left on device
Setting pipeline to NULL ...
Freeing pipeline ...