How to setup V4L2SRC exposure time?

Nicolas Dufresne nicolas at ndufresne.ca
Sat Jan 18 16:15:28 UTC 2020


Le samedi 18 janvier 2020 à 06:29 -0600, jeyp4 a écrit :
> Is there any way to set exposure time for v4l2src USB camera?

Note that there is slight variation between cameras, so first step is to list
the controls that are available with your model. The simpliest way is to use
v4l2-ctl utility, GStreamer does not offer any way to list the controls at the
moment.

So to list my controls here, I do the following (my camera is /dev/video0, don't
forget to adapt).

   v4l2-ctl -d /dev/video0 -L
                        brightness 0x00980900 (int)    : min=0 max=255 step=1 default=128 value=128
                          contrast 0x00980901 (int)    : min=0 max=255 step=1 default=32 value=32
                        saturation 0x00980902 (int)    : min=0 max=100 step=1 default=64 value=64
                               hue 0x00980903 (int)    : min=-180 max=180 step=1 default=0 value=0
    white_balance_temperature_auto 0x0098090c (bool)   : default=1 value=1
                             gamma 0x00980910 (int)    : min=90 max=150 step=1 default=120 value=120
              power_line_frequency 0x00980918 (menu)   : min=0 max=2 default=1 value=1
   				0: Disabled
   				1: 50 Hz
   				2: 60 Hz
         white_balance_temperature 0x0098091a (int)    : min=2800 max=6500 step=1 default=4000 value=4000 flags=inactive
                         sharpness 0x0098091b (int)    : min=0 max=7 step=1 default=2 value=2
            backlight_compensation 0x0098091c (int)    : min=0 max=2 step=1 default=1 value=1
                     exposure_auto 0x009a0901 (menu)   : min=0 max=3 default=3 value=1
   				1: Manual Mode
   				3: Aperture Priority Mode
                 exposure_absolute 0x009a0902 (int)    : min=4 max=1250 step=1 default=156 value=80
            exposure_auto_priority 0x009a0903 (bool)   : default=0 value=1

So on my model, it means I need to set exposure_auto=1 (manual), and then I can
control the exposure with "exposure_absolute". It's not clear if we can convert
these values to time, I would need to observe the effect on framereate. So two
ways to change the controls. If you want to do that using GStreamer, you need to
use the extra-controls property. Here's an example:

   gst-launch-1.0 v4l2src extra-controls=s,exposure_auto=1,exposure_absolute=40 ! videoconvert ! autovideosink

In a GStreamer app, you can set that property at run-time. V4L2 also allow
another process to change this values, so you can use v4l2-ctl while GStreamer
is running to experiment.

  v4l2-ctl -d /dev/video0 -c exposure_absolute=100

If you would like to take control of this programatically, without GStreamer or
v4l2-ctl, please refer to the control documentation.

https://www.kernel.org/doc/html/v4.10/media/uapi/v4l/control.html

regards,
Nicolas



More information about the gstreamer-devel mailing list