v4l2src

v4l2src can be used to capture video from v4l2 devices, like webcams and tv cards.

Example launch lines

 gst-launch-1.0 v4l2src ! xvimagesink

This pipeline shows the video captured from /dev/video0 tv card and for webcams.

 gst-launch-1.0 v4l2src ! jpegdec ! xvimagesink

This pipeline shows the video captured from a webcam that delivers jpeg images.

Since 1.14, the use of libv4l2 has been disabled due to major bugs in the emulation layer. To enable usage of this library, set the environment variable GST_V4L2_USE_LIBV4L2=1.

Hierarchy

GObject
    ╰──GInitiallyUnowned
        ╰──GstObject
            ╰──GstElement
                ╰──GstBaseSrc
                    ╰──GstPushSrc
                        ╰──v4l2src

Factory details

Authors: – Edgard Lima , Stefan Kost

Classification:Source/Video

Rank – primary

Plugin – gstvideo4linux2

Package – GStreamer Good Plug-ins git

Pad Templates

src

image/jpeg:
video/mpeg:
    mpegversion: 4
   systemstream: false
video/mpeg:
    mpegversion: 2
video/mpegts:
   systemstream: true
video/x-bayer:
         format: { bggr, gbrg, grbg, rggb }
          width: [ 1, 32768 ]
         height: [ 1, 32768 ]
      framerate: [ 0/1, 2147483647/1 ]
video/x-dv:
   systemstream: true
video/x-fwht:
video/x-h263:
        variant: itu
video/x-h264:
  stream-format: { (string)byte-stream, (string)avc }
      alignment: au
video/x-h265:
  stream-format: byte-stream
      alignment: au
video/x-pwc1:
          width: [ 1, 32768 ]
         height: [ 1, 32768 ]
      framerate: [ 0/1, 2147483647/1 ]
video/x-pwc2:
          width: [ 1, 32768 ]
         height: [ 1, 32768 ]
      framerate: [ 0/1, 2147483647/1 ]
video/x-raw:
         format: { RGB16, BGR, RGB, GRAY8, GRAY16_LE, GRAY16_BE, YVU9, YV12, YUY2, YVYU, UYVY, Y42B, Y41B, YUV9, NV12_64Z32, NV24, NV61, NV16, NV21, NV12, I420, BGRA, BGRx, ARGB, xRGB, BGR15, RGB15 }
          width: [ 1, 32768 ]
         height: [ 1, 32768 ]
      framerate: [ 0/1, 2147483647/1 ]
video/x-sonix:
          width: [ 1, 32768 ]
         height: [ 1, 32768 ]
      framerate: [ 0/1, 2147483647/1 ]
video/x-vp8:
video/x-vp9:
video/x-wmv:
     wmvversion: 3
         format: WVC1

Presencealways

Directionsrc


Signals

prepare-format

prepare_format_callback (GstElement * v4l2src,
                         gint fd,
                         GstCaps * caps,
                         gpointer udata)
def prepare_format_callback (v4l2src, fd, caps, udata):
    #python callback for the 'prepare-format' signal
function prepare_format_callback(v4l2src: GstElement * v4l2src, fd: gint fd, caps: GstCaps * caps, udata: gpointer udata): {
    // javascript callback for the 'prepare-format' signal
}

This signal gets emitted before calling the v4l2 VIDIOC_S_FMT ioctl (set format). This allows for any custom configuration of the device to happen prior to the format being set. This is mostly useful for UVC H264 encoding cameras which need the H264 Probe & Commit to happen prior to the normal Probe & Commit.

Parameters:

v4l2src

the v4l2src instance

fd

the file descriptor of the current device

caps

the caps of the format being set

udata
No description available

Properties

blocksize

“blocksize” guint

Size in bytes to read per buffer (-1 = default)

Flags : Read / Write

Default value : 4096


brightness

“brightness” gint

Picture brightness, or more precisely, the black level

Flags : Read / Write

Default value : 0


contrast

“contrast” gint

Picture contrast or luma gain

Flags : Read / Write

Default value : 0


device

“device” gchararray

Device location

Flags : Read / Write

Default value : /dev/video0


device-fd

“device-fd” gint

File descriptor of the device

Flags : Read

Default value : -1


device-name

“device-name” gchararray

Name of the device

Flags : Read

Default value : NULL


do-timestamp

“do-timestamp” gboolean

Apply current stream time to buffers

Flags : Read / Write

Default value : false


extra-controls

“extra-controls” GstStructure *

Additional v4l2 controls for the device. The controls are identified by the control name (lowercase with '_' for any non-alphanumeric characters).

Flags : Read / Write


flags

“flags” V4l2device-type-flags

Device type flags

Flags : Read

Default value : (none)


force-aspect-ratio

“force-aspect-ratio” gboolean

When enabled, the pixel aspect ratio queried from the device or set with the pixel-aspect-ratio property will be enforced.

Flags : Read / Write

Default value : true


hue

“hue” gint

Hue or color balance

Flags : Read / Write

Default value : 0


io-mode

“io-mode” V4l2iomode

IO Mode

Flags : Read / Write

Default value : auto (0)


name

“name” gchararray

The name of the object

Flags : Read / Write / Construct

Default value : NULL


norm

“norm” V4l2_tv_norms

TV norm

Flags : Read / Write

Default value : none (0)


num-buffers

“num-buffers” gint

Number of buffers to output before sending EOS (-1 = unlimited)

Flags : Read / Write

Default value : -1


parent

“parent” GstObject *

The parent of the object

Flags : Read / Write


pixel-aspect-ratio

“pixel-aspect-ratio” gchararray

The pixel aspect ratio of the device. This overwrites the pixel aspect ratio queried from the device.

Flags : Read / Write

Default value : NULL


saturation

“saturation” gint

Picture color saturation or chroma gain

Flags : Read / Write

Default value : 0


typefind

“typefind” gboolean

Run typefind before negotiating (deprecated, non-functional)

Flags : Read / Write

Default value : false


Named constants

V4l2device-type-flags

Members

capture (0x00000001) – Device supports video capture
output (0x00000002) – Device supports video playback
overlay (0x00000004) – Device supports video overlay
vbi-capture (0x00000010) – Device supports the VBI capture
vbi-output (0x00000020) – Device supports the VBI output
tuner (0x00010000) – Device has a tuner or modulator
audio (0x00020000) – Device has audio inputs or outputs

V4l2iomode

Members

auto (0) – GST_V4L2_IO_AUTO
rw (1) – GST_V4L2_IO_RW
mmap (2) – GST_V4L2_IO_MMAP
userptr (3) – GST_V4L2_IO_USERPTR
dmabuf (4) – GST_V4L2_IO_DMABUF
dmabuf-import (5) – GST_V4L2_IO_DMABUF_IMPORT

V4l2_tv_norms

Members

none (0) – none
NTSC (45056) – NTSC
NTSC-M (4096) – NTSC-M
NTSC-M-JP (8192) – NTSC-M-JP
NTSC-M-KR (32768) – NTSC-M-KR
NTSC-443 (16384) – NTSC-443
PAL (255) – PAL
PAL-BG (7) – PAL-BG
PAL-B (1) – PAL-B
PAL-B1 (2) – PAL-B1
PAL-G (4) – PAL-G
PAL-H (8) – PAL-H
PAL-I (16) – PAL-I
PAL-DK (224) – PAL-DK
PAL-D (32) – PAL-D
PAL-D1 (64) – PAL-D1
PAL-K (128) – PAL-K
PAL-M (256) – PAL-M
PAL-N (512) – PAL-N
PAL-Nc (1024) – PAL-Nc
PAL-60 (2048) – PAL-60
SECAM (16711680) – SECAM
SECAM-B (65536) – SECAM-B
SECAM-G (262144) – SECAM-G
SECAM-H (524288) – SECAM-H
SECAM-DK (3276800) – SECAM-DK
SECAM-D (131072) – SECAM-D
SECAM-K (1048576) – SECAM-K
SECAM-K1 (2097152) – SECAM-K1
SECAM-L (4194304) – SECAM-L
SECAM-Lc (8388608) – SECAM-Lc

The results of the search are