Linux V4L2 notes(1)

(The notes is intended for capture stream/input device only.)

Video inputs and outputs are physical connectors of a device.

VIDIOC_ENUMINPUT: get the available inputs.

  • VIDIOC_S_INPUT: select a different input.
    • Note: audio and video inputs are associated: selecting a video source also selects an audio source.
  • VIDIOC_G_INPUT: return the index of current video input.
  • VIDIOC_QUERYCAP

struct v4l2_capability

{

               _u8 driver[16];  // name of the driver

               _u8 card[32];    // name of the device

               -u8 bus_info[32]; // location of the device in the system, e.g. “PCI Slot 4”

               _u32 version;

               _u32 capabilities;  // bit definition to indicate device capabilities

}

some capabilities Flags: V4L2_CAP_VIDEO_(VBI)_CAPTURE/OUTPUT/OVERLAY,   V4L2_CAP_AUDIO/ READWRITE/ASYNCIO/STREAMING.

  • VIDIOC_ENUM/G/S/TRY_FMT:  data format and layout of an image in memory.

struct v4l2_pix_format {

               _u32 width;

               _u32 height;

               _u32 pixelformat;

                        field;

               _u32 bytesperline;

               _u32 sizeofimage;

                         colorspace

}

  • VIDIOC_CROPCAP, VIDIOC_S_CROP

Struct v4l2_cropcap {

enum v4l2_buf_type type; // V4L2_BUF_TYPE_VIDEO_CAPTURE/OUTPUT/OVERLEY.

Struct v4l2_rect bound;      // the capturing window, in unit of pixels.

Struct v4l2_rect defrect;    // default cropping rectangle

Struct v4l2_fract;   // pixel aspect(y/x) when no scaling is applied

}

Note:

  1. the original source image size(.bound) is returned by ioctl(VIDIOC_CROPCAP);
  2. the default cropping size (.defrect) is returned by it, too.
  3. to set a new cropping size, use VIDIOC_S_CROP.
  4. To use scaling, set format.fmt.pix.width/height, to be different from the cropping size.
  • VIDIOC_S/G_PARM  optimize the video capture process as well as I/O.

Struct v4l2_streamparm

{

               enum v4l2_buf_type type;

               union parm

                              struct v4l2_captureparm capture;

                              struct v4l2_outputparm output;

}

struct v4l2_captureparm

{

                              capability;           // V4L2_CAP_TIMEPERFRAME  (the frame skipping/repeating controlled by the timeperframe field is supported.

                              capuremode;     //  V4L2_MODE_HIGHQUALITY (intended for still imaging application).

               struct v4l2_fract timeperframe;  //  for GET, it is the nominal frame period determined by the current video standard; for SET, it is the desired period, in seconds. Driver might skip frames, to save I/O bandwidth. Only effective when V4L2_CAP_TIMEPERFRAME is set; a “zero” will reset to nominal frame period.

                              extendedmode;

                              readbuffers;

}

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s