Path: blob/master/Documentation/DocBook/v4l/dev-capture.xml
10821 views
<title>Video Capture Interface</title>12<para>Video capture devices sample an analog video signal and store3the digitized images in memory. Today nearly all devices can capture4at full 25 or 30 frames/second. With this interface applications can5control the capture process and move images from the driver into user6space.</para>78<para>Conventionally V4L2 video capture devices are accessed through9character device special files named <filename>/dev/video</filename>10and <filename>/dev/video0</filename> to11<filename>/dev/video63</filename> with major number 81 and minor12numbers 0 to 63. <filename>/dev/video</filename> is typically a13symbolic link to the preferred video device. Note the same device14files are used for video output devices.</para>1516<section>17<title>Querying Capabilities</title>1819<para>Devices supporting the video capture interface set the20<constant>V4L2_CAP_VIDEO_CAPTURE</constant> or21<constant>V4L2_CAP_VIDEO_CAPTURE_MPLANE</constant> flag in the22<structfield>capabilities</structfield> field of &v4l2-capability;23returned by the &VIDIOC-QUERYCAP; ioctl. As secondary device functions24they may also support the <link linkend="overlay">video overlay</link>25(<constant>V4L2_CAP_VIDEO_OVERLAY</constant>) and the <link26linkend="raw-vbi">raw VBI capture</link>27(<constant>V4L2_CAP_VBI_CAPTURE</constant>) interface. At least one of28the read/write or streaming I/O methods must be supported. Tuners and29audio inputs are optional.</para>30</section>3132<section>33<title>Supplemental Functions</title>3435<para>Video capture devices shall support <link36linkend="audio">audio input</link>, <link37linkend="tuner">tuner</link>, <link linkend="control">controls</link>,38<link linkend="crop">cropping and scaling</link> and <link39linkend="streaming-par">streaming parameter</link> ioctls as needed.40The <link linkend="video">video input</link> and <link41linkend="standard">video standard</link> ioctls must be supported by42all video capture devices.</para>43</section>4445<section>46<title>Image Format Negotiation</title>4748<para>The result of a capture operation is determined by49cropping and image format parameters. The former select an area of the50video picture to capture, the latter how images are stored in memory,51&ie; in RGB or YUV format, the number of bits per pixel or width and52height. Together they also define how images are scaled in the53process.</para>5455<para>As usual these parameters are <emphasis>not</emphasis> reset56at &func-open; time to permit Unix tool chains, programming a device57and then reading from it as if it was a plain file. Well written V4L258applications ensure they really get what they want, including cropping59and scaling.</para>6061<para>Cropping initialization at minimum requires to reset the62parameters to defaults. An example is given in <xref63linkend="crop" />.</para>6465<para>To query the current image format applications set the66<structfield>type</structfield> field of a &v4l2-format; to67<constant>V4L2_BUF_TYPE_VIDEO_CAPTURE</constant> or68<constant>V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE</constant> and call the69&VIDIOC-G-FMT; ioctl with a pointer to this structure. Drivers fill70the &v4l2-pix-format; <structfield>pix</structfield> or the71&v4l2-pix-format-mplane; <structfield>pix_mp</structfield> member of the72<structfield>fmt</structfield> union.</para>7374<para>To request different parameters applications set the75<structfield>type</structfield> field of a &v4l2-format; as above and76initialize all fields of the &v4l2-pix-format;77<structfield>vbi</structfield> member of the78<structfield>fmt</structfield> union, or better just modify the79results of <constant>VIDIOC_G_FMT</constant>, and call the80&VIDIOC-S-FMT; ioctl with a pointer to this structure. Drivers may81adjust the parameters and finally return the actual parameters as82<constant>VIDIOC_G_FMT</constant> does.</para>8384<para>Like <constant>VIDIOC_S_FMT</constant> the85&VIDIOC-TRY-FMT; ioctl can be used to learn about hardware limitations86without disabling I/O or possibly time consuming hardware87preparations.</para>8889<para>The contents of &v4l2-pix-format; and &v4l2-pix-format-mplane;90are discussed in <xref linkend="pixfmt" />. See also the specification of the91<constant>VIDIOC_G_FMT</constant>, <constant>VIDIOC_S_FMT</constant>92and <constant>VIDIOC_TRY_FMT</constant> ioctls for details. Video93capture devices must implement both the94<constant>VIDIOC_G_FMT</constant> and95<constant>VIDIOC_S_FMT</constant> ioctl, even if96<constant>VIDIOC_S_FMT</constant> ignores all requests and always97returns default parameters as <constant>VIDIOC_G_FMT</constant> does.98<constant>VIDIOC_TRY_FMT</constant> is optional.</para>99</section>100101<section>102<title>Reading Images</title>103104<para>A video capture device may support the <link105linkend="rw">read() function</link> and/or streaming (<link106linkend="mmap">memory mapping</link> or <link107linkend="userp">user pointer</link>) I/O. See <xref108linkend="io" /> for details.</para>109</section>110111<!--112Local Variables:113mode: sgml114sgml-parent-document: "v4l2.sgml"115indent-tabs-mode: nil116End:117-->118119120