# 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

## Implemented interfaces

    GstURIHandler
    GstTuner
    GstColorBalance
    GstVideoOrientation

## Factory details

Authors: – Edgard Lima , Stefan Kost

Classification: – `Source/Video`

Rank – primary

Plugin – video4linux2

Package – GStreamer Good Plug-ins

## Pad Templates

### `src`

    video/x-raw(memory:DMABuf):
             format: DMA_DRM
         drm-format: { (string)RGB8, (string)AR15, (string)XR15_BE, (string)AR15_BE, (string)RG16, (string)RG16_BE, (string)RG24, (string)BG24, (string)AR24, (string)RA24, (string)RX24, (string)AB24, (string)XB24, (string)BA24, (string)AR30, (string)"R8\ \ ", (string)"R4\ \ ", (string)"R10\ ", (string)"R12\ ", (string)"R16\ ", (string)"R16\ _BE", (string)GR88, (string)YUV9, (string)YVU9, (string)YUYV, (string)UYVY, (string)VYUY, (string)YU11, (string)NV12:0x0400000000000001, (string)NV24, (string)NV42, (string)NV12:0x0b00000000000001, (string)P010, (string)NV61, (string)NV16, (string)NV21, (string)NV12:0x0400000000000002, (string)NV12, (string)YU16, (string)YVYU, (string)YV12, (string)YU12, (string)BX24, (string)XR24, (string)XR15 }
              width: [ 1, 32768 ]
             height: [ 1, 32768 ]
          framerate: [ 0/1, 2147483647/1 ]

    video/x-raw(memory:DMABuf, format:Interlaced):
             format: DMA_DRM
         drm-format: { (string)RGB8, (string)AR15, (string)XR15_BE, (string)AR15_BE, (string)RG16, (string)RG16_BE, (string)RG24, (string)BG24, (string)AR24, (string)RA24, (string)RX24, (string)AB24, (string)XB24, (string)BA24, (string)AR30, (string)"R8\ \ ", (string)"R4\ \ ", (string)"R10\ ", (string)"R12\ ", (string)"R16\ ", (string)"R16\ _BE", (string)GR88, (string)YUV9, (string)YVU9, (string)YUYV, (string)UYVY, (string)VYUY, (string)YU11, (string)NV12:0x0400000000000001, (string)NV24, (string)NV42, (string)NV12:0x0b00000000000001, (string)P010, (string)NV61, (string)NV16, (string)NV21, (string)NV12:0x0400000000000002, (string)NV12, (string)YU16, (string)YVYU, (string)YV12, (string)YU12, (string)BX24, (string)XR24, (string)XR15 }
              width: [ 1, 32768 ]
             height: [ 1, 32768 ]
          framerate: [ 0/1, 2147483647/1 ]
     interlace-mode: alternate
    image/jpeg:
             parsed: true
    video/mpeg:
        mpegversion: 4
       systemstream: false
    video/mpeg:
        mpegversion: { (int)1, (int)2 }
    video/mpegts:
       systemstream: true
    video/x-bayer:
             format: { bggr, gbrg, grbg, rggb, bggr10le, gbrg10le, grbg10le, rggb10le, bggr12le, gbrg12le, grbg12le, rggb12le, bggr14le, gbrg14le, grbg14le, rggb14le, bggr16le, gbrg16le, grbg16le, rggb16le }
              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, ABGR, xBGR, RGBA, RGBx, BGR10A2_LE, BGR15, GRAY8, GRAY16_LE, GRAY16_BE, YUV9, YVU9, YUY2, YVYU, UYVY, Y41B, NV12_64Z32, NV12_8L128, NV12_10BE_8L128, NV24, NV12_16L32S, P010_10LE, NV61, NV16, NV21, NV12, Y42B, YV12, I420, ARGB, xRGB, BGRA, BGRx, 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

    video/x-raw(format:Interlaced):
             format: { RGB16, BGR, RGB, ABGR, xBGR, RGBA, RGBx, BGR10A2_LE, BGR15, GRAY8, GRAY16_LE, GRAY16_BE, YUV9, YVU9, YUY2, YVYU, UYVY, Y41B, NV12_64Z32, NV12_8L128, NV12_10BE_8L128, NV24, NV12_16L32S, P010_10LE, NV61, NV16, NV21, NV12, Y42B, YV12, I420, ARGB, xRGB, BGRA, BGRx, RGB15 }
              width: [ 1, 32768 ]
             height: [ 1, 32768 ]
          framerate: [ 0/1, 2147483647/1 ]
     interlace-mode: alternate

Presence – always

Direction – src

Object type – GstPad

## 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

Flags: Run Last

## Properties

### 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

### crop-bottom

    “crop-bottom” guint

Number of pixels to crop from the bottom edge of captured video stream

Flags : Read / Write

Default value : 0

Since : 1.22

### crop-bounds

    “crop-bounds” GstValueArray *

Crop bounding region. All crop regions must lie within this region. The bounds are represented as a four element array, that descibes the [x, y, width, height] of the area.

The size and position of the crop bounds will only be known, once the v4l2 device is opened and the input source selected. Applications can connect to the "notify::crop-bounds" signal to be notified when the bounding region is updated, and set an appropriate crop region.

Flags : Read

Since : 1.22

### crop-left

    “crop-left” guint

Number of pixels to crop from the left edge of captured video stream

Flags : Read / Write

Default value : 0

Since : 1.22

### crop-right

    “crop-right” guint

Number of pixels to crop from the right edge of captured video stream

Flags : Read / Write

Default value : 0

Since : 1.22

### crop-top

    “crop-top” guint

Number of pixels to crop from the top edge of captured video stream

Flags : Read / Write

Default value : 0

Since : 1.22

### 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

### 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

Since : 1.2

### flags

    “flags” GstV4l2DeviceTypeFlags *

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

Since : 1.2

### hue

    “hue” gint

Hue or color balance

Flags : Read / Write

Default value : 0

### io-mode

    “io-mode” GstV4l2IOMode *

IO Mode

Flags : Read / Write

Default value : auto (0)

### norm

    “norm” V4L2_TV_norms *

TV norm

Flags : Read / Write

Default value : none (0)

### 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

Since : 1.2

### saturation

    “saturation” gint

Picture color saturation or chroma gain

Flags : Read / Write

Default value : 0

## Named constants

### GstV4l2DeviceTypeFlags

#### 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

### GstV4l2IOMode

#### 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