# Changing power line frequency for webcam



## twschulz (Dec 21, 2020)

I've been using webcams with FreeBSD, but since I live in a country that has 50 Hz power frequency, there is always flicker from the lights as the camera by default uses 60 Hz. I know you can change the frequency in other operating systems, so I investigated, and it seems the v4l way is to use `v4l2-ctl` with something like:

`v4l2-ctl --set-ctrl=power_line_frequency=1`

However, when I run this command (or almost any switches) on FreeBSD, I get the following:


```
# v4l2-ctl -L
Unable to detect what device /dev/video0 is, exiting.
```

Is there something I can do to help `v4l2-ctl` do the right thing? If there's a different way to configure this, please let me know.

I would really like to have flicker-free video under FreeBSD and I suspect some FreeBSD user in a 50 Hz country has run into this issue before.


----------



## twschulz (Jan 1, 2021)

To answer my own question, it seems that `v4l2-ctl` has some Linux-isms in how it determines the device. It uses uevent in the Linux /sys filesystem. That functionality is not being handled in webcamd, so it fails. Changing to code to force video, does give you the menu listing with -L, so that works.

You can then run the --set-ctrl, but there seems to be some difference in how getsubopt() works between FreeBSD and glibc. You can trick the program to work with a command like this:


```
./v4l2-ctl --set-ctrl=power_line_frequency=power_line_frequency=1
```

Then, the flicker is gone in the video. That's great!

So, by hacking on the code and messing with the input, I can get the thing to work, but this is not a general solution.

I have filed a bug on this first bit at least (PR 252327).


----------

