Webcam Autofocus

Hello, everyone,

I have a question about the autofocus of the webcam. I would like to switch it off. 
When I go to the local side of the M-JPEG streamer I can turn off the focus and set a manual value. Unfortunately this setting is not saved. 
I then sent the following commands via SSH:
sudo v4l2-ctl --set-ctrl=focus_auto=0
sudo v4l2-ctl --set-ctrl=focus_absolute=40

These commands disable the autofocus and set a manual focus. Unfortunately you have to send them again after each restart. 
So I wanted to ask you if there is a possibility to set these commands always at system start.
Unfortunately an entry in the rc.local did not work. 

Comments

  • Try adding it to /usr/local/Repetier-Setup/bin/startAllCams at the end. That script is run to start all mjpg_streamer when new webcams are available. So there it should work.
  • Many thanks for the quick help. This works great. The autofocus is now off after a restart and the manual focus is set.
    Thanks a lot.
  • Hello i´m new @ ssh and whre i can find my cam name?
    I would also like to switch off the autofocus (Cannot open device /dev/video0, exiting.)

  • ps aux | grep mjpg

    shows running mjpg streamer instances with command line. The -d parameter is your device and you also see the assigned port. From there it should be easy to change the parameter.


    For some reason the buster now seems to show multiple entries per webcam but only one will work.

  • Repetier said:

    ps aux | grep mjpg

    shows running mjpg streamer instances with command line. The -d parameter is your device and you also see the assigned port. From there it should be easy to change the parameter.


    For some reason the buster now seems to show multiple entries per webcam but only one will work.

    hmm OK thanks for the answer  ;)

    So I get this displayed
    Sl   19:44   0:01 /usr/local/bin/mjpg_streamer -i /usr/local/lib/mjpg-streamer/input_uvc.so -d /dev/video0 --fps 24 -q 85 -r 1280x720  -o /usr/local/lib/mjpg-streamer/output_http.so -p 8082 -w /usr/local/share/mjpg-streamer/www -b


    I can not interpret it so well what and how to understand it or how I find out how I enter my cam :/
    sudo v4l2-ctl --set-ctrl=focus_auto=0


  • From -d /dev/video0 you see device is /dev/video0 so command is
    sudo -d /dev/video0 v4l2-ctl --set-ctrl=focus_auto=0
  • So I get this message
    sudo: invalid option -- 'd'

    when i use  

    sudo -d /dev/video0 v4l2-ctl --set-ctrl=focus_auto=0
     :/ 
  • Pasted it in wrong position

    sudo v4l2-ctl -d /dev/video0 --set-ctrl=focus_auto=0

    should do it.

  • super , thanks for help, now works fine also the absolute command B)

    now i just need the right command to set these commands always at system start
    you said "Try adding it to /usr/local/Repetier-Setup/bin/startAllCams at the end"
    I tried something around but didn't find the right one :/

  • What is the problem. 
    sudo nano  /usr/local/Repetier-Setup/bin/startAllCams

    and add it after the last line. Then it always runs after the streamer is started.

  • Repetier said:
    What is the problem. 
    that was a new command for me (nano)

    thaks for this "noob" howto ;)  now works all fine with the cam as I imagine it
    i love the repetier server to make my prints!

    thanks a lot 
    • Greetings from Germany
  • edited September 8
    pi@RepetierServer:~ $ ps aux | grep mjpg
    root      1360  0.4  0.2  49264 19152 ?        Sl   12:58   0:02 /usr/local/bin/mjpg_streamer -i /usr/local/lib/mjpg-streamer/input_uvc.so -d /dev/video0 --fps 30 -q 85 -r 1920x1080  -o /usr/local/lib/mjpg-streamer/output_http.so -p 8082 -w /usr/local/share/mjpg-streamer/www
    pi        3439  0.0  0.0   7540  1920 pts/1    S+   13:08   0:00 grep --color=auto mjpg

    pi@RepetierServer:~ $ sudo v4l2-ctl -d /dev/video0 --set-ctrl=focus_auto=0
    unknown control 'focus_auto'

    pi@RepetierServer:~ $ sudo v4l2-ctl -d /dev/video0 --set-ctrl=focus_absolute=40
    unknown control 'focus_absolute'

    not sure why, 

    pi@RepetierServer:~ $ sudo cat /etc/os-release
    PRETTY_NAME="Raspbian GNU/Linux 12 (bookworm)"
    NAME="Raspbian GNU/Linux"
    VERSION_ID="12"
    VERSION="12 (bookworm)"
    VERSION_CODENAME=bookworm
    ID=raspbian
    ID_LIKE=debian
  • v4l2-ctl -l -d /dev/video0

    will list available controls for your device.
  • edited September 8
    Repetier said:
    v4l2-ctl -l -d /dev/video0

    will list available controls for your device.
    Thanks, i viewed the available command list by using the command sudo v4l2-ctl -d /dev/video0 --list-ctrls
    and i found that my camera doesn't support auto focus :# 
    i was using the LG V23g camera and i verified it from the MJPG-streamer controls
    thanks a lot by the way!
Sign In or Register to comment.