How to fix webcam autozooming?

Generic Chinese webcam

During the pandemic lots of people have moved their jobs out of their offices to remote working, along with this change many are now forced to participate in teleconferences, meetings where they need to be visible. They either use the built-in camera of their laptop or picked up an USB web camera, like me. Lots of people face the same issue, that I encountered, my camera refocused from time-to-time, making the other people uncomfortable.

In this article I will show, how Windows 10 users may address this issue manually, or using a tool to readjust their settings.

Background

In the early days of the pandemic, I picked up a cheap 2K camera off Aliexpress, and I’m quite impressed the way it just works. The image is quite sharp, and is far better, than what I would get from a built-in fix focus laptop camera. There is one issue however, that I have not expected. The camera does not always finds it’s focus, so it readjust itself from time to time, and it was mentioned by other parties in my calls, as annoying.

I dug into the topic and learned it is not an exclusive issue, and it is characteristic to all high resolution cameras. The focus points are rarely adjustable with the plug-and-play cameras, and unless you have a single colored background, they feel obliged to refocus from time to time.

This is not an exclusively Windows issue, however that’s the main platform I use these days so that’s where I tried solving it.

The camera focus in a fix workplace can usually be fixed. Once you set it up, there is no real reason to readjust it. So if you own a high-end camera with it’s own setup software, you could just switch to manual focus, and adjust it to your liking. This won’t work for most cameras and applications.

In my case, whenever Windows opens the camera, like when you open the Camera app or Teams, and sometimes even when you just switch windows, the camera is reset. In my case it resets to 0 focal length causing really blurry images.

How to manually turn autofocus off?

It sounds easy. Just go to your Camera app change to pro-mode and change the focus slider according to your desire. This setting will be lost however, when you turn the application off and try to access the camera in any other application.

What’s the camera properties dialog?

The camera properties dialog is the key to adjusting your camera settings and is quite difficult to open it from standard Windows settings. You can adjust all settings allowed by your camera, creating a much better looking image.

The settings in this dialog are NOT PERMANENT! Once you reboot or just unplug the camera, they will be reset to defaults. I have yet to find a tool that restores the presets I use for brightening up the image.

Camera properties dialog from OBS

The dialog can be opened from a few application such as Skype, OBS, Teams to access the settings and set your own focus up.

How to disable autofocus in OBS?

OBS is the go-to choice for streamers, and allows you to set up a virtual camera with neat features, like subtitles.

OBS allows you to to access your camera setting dialog for your camera device.

You can in theory use this virtual camera for all applications, but this requires a chunky OBS running in the background, so I would not recommend it as a daily driver! There are tons of instructions on the Internet, helping to learn and use OBS.

How to disable autofocus in Microsoft Teams?

Turning automatic adjustment off in Microsoft Teams

Microsoft Teams is very widely used in enterprise environments, and has a particular extra feature, that makes this issue a little worse.

It has a well hidden setting that allows it to control your camera setting. It’s quite neat, as it can adjust everything for you! However it does not actually do color correction or such useful features, it just resets all your camera settings and you are back to square one with it. What’s worse it will do that automatically in a call, so even if you adjust the focal length with a script, it will just mess it up.

If you want to use manual adjustment, just turn this feature off, you will be better off without!

Turning it off will also enable the menu for opening the camera setting dialog, so you’d be able to set your camera up the way you like it.

Script to reset camera focus

I use several applications that should all have the same camera settings and I don’t want to dig into the application setup each time I wanted to show my face. So I had to come up with a solution that works on every application.

OBS virtual camera was my first choice, but I don’t like the idea of running such a big application in the background. I don’t want to add other content to my camera feed, so it’s really and overkill. Even using than I would have to readjust the camera each time I start it up.

Fortunately some guys from the internet came to the rescue. After some extensive research I found the FocusUF tool, that is able to modify your camera’s autofocus settings. The creator of the tool came up with it, because he was struggling with the same issue on a Microsoft LifeCam HD-5000.

I downloaded the file from the win32 directory, and extracted it. I found that most applications actually need to reenable the autofocus, than turn it off again before the focal length can be adjusted.

So I’ve created a small batch file, and placed it on my desktop. It first enables autofocus, disables it and sets up the focal length I would normally set in the focus slider of the property dialog. You can create it yourself, and adjust the name of your camera to what the command FocusUF -l gives you! Don’t forget to adjust the location of the downloaded FocusUF.exe, and your favourite focal length!

@echo off
set CAMERA="YOUR CAMERA"

set FOCUSUF_PATH="Directory containing FocusUF.exe"
%FOCUSUF_PATH%\FocusUF.exe -n %CAMERA% -fa
%FOCUSUF_PATH%\FocusUF.exe -n %CAMERA% -fm
%FOCUSUF_PATH%\FocusUF.exe -n %CAMERA% -f YOUR_FOCUS

Script to open the camera settings dialog

I’ve also found a way here to open the camera properties dialog, using ffmpeg. This is not a very neat way of doing it, but as long as it works…

I recommend to download ffmpeg from their download site and use a script like the one below.

@echo off
set CAMERA="YOUR CAMERA"
set FFMPEG_PATH="Directory containing ffmpeg.exe"
%FFMPEG_PATH%\ffmpeg.exe -f dshow -show_video_device_dialog true -i video=%CAMERA%

Using the scripts from shortcuts

As I don’t want script windows popping up on my display every time I use these scripts, I created a shortcut on my desktop, and set it to run the scripts minimised

I don’t want to dig into the desktop every time I open my camera, so I also assigned it a keyboard shortcut. This allows a quick focus readjust when Windows resets my focus.

Rolling it into one

Since this utility does not allow adjusting the color of the camera, I took the liberty and modified it a bit.

My enhanced version is available on GitHub and you can download the binary build from here. This utility can accept multiple parameters as an input and allows modification of some camera color parameters as well.

FocusUF.exe --help
FocusUF-ng 1.3.0.0
Get the source at https://github.com/gpapp/FocusUF

Usage: FocusUF [--help | -?] [--list-cameras | -l]
               [--focus-mode-manual | -fm] [--focus-mode-auto | -fa]
               [--set-focus <value> | -f <value>]
               [--exposure-mode-manual | -em] [--exposure-mode-auto | -ea]
               [--set-exposure <value> | -e <value>]
               [--set-brightness <value> | -b <value>]
               [--set-contrast <value> | -c <value>]
               [--set-saturation <value> | -s <value>]
               [--set-gamma <value> | -g <value>]
               [--camera-name <name> | -n <name>]
               [--and {more operations...}]

So if you want, you can rewrite your script above, as follows, which will be faster and you can set your color correction values to your liking using the parameters.

"Directory containing FocusUF.exe"\FocusUF.exe -n "YOUR CAMERA" -fa --and -fm --and -f YOUR_FOCUS

If you want to support my projects, all donations are welcome!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.