soyersoyer / cameractrls

Camera controls for Linux
Other
590 stars 24 forks source link

Razer Kiyo Pro Ultra PCAP needed #19

Open soyersoyer opened 1 year ago

soyersoyer commented 1 year ago

The Razer Kiyo Pro Ultra is the new 'best webcam'. It would be cool to support its special features. If you have one, please capture USB communication with Wireshark while changing special settings in windows with synapse.

pohlt commented 1 year ago

I should get mine next week and will hopefully find the time to provide the required information...

soyersoyer commented 1 year ago

That's cool! I will need an usb vendor and product id, the output of the lsusb -v -d vendorid:productid, and the usb traffic sniffed with wireshark+USBPcap for every non standard control while changing its values. One control per pcap file to make it easier, and the values you set.

pohlt commented 1 year ago

Got my Kiyo Pro Ultra this morning. \o/

"non standard" are all the messages which are not identifed in the info string I guess: "Zoom (absolute)" is recognized, "Unit 6 control 0x1" is not, right?

Do you need:

Should I send it as PM? I can also put it on my Google Drive and share the folder with you. What's most convenient for you?

soyersoyer commented 1 year ago

Yes, there are standard uvc controls, that wireshark/linux uvc/anything handles well. Other controls can usually be used with extension units. Could you filter with frame.protocols == "usb:usbvideo"? Then you can upload them to google drive and post the links here or create a git repo for them.

pohlt commented 1 year ago

Here's a first try with the preview resolution and the 2d/3d noise reduction. Please find the captures and the desciption file here.

Once I see how you would add it to your repo, I might be able to do the rest by myself and create a PR.

USB ID: 1532:0E08 (rev 0821)

soyersoyer commented 1 year ago

These look different than the kiyo pro traffic. Where is the "Unit 6 control 0x1" thing?

pohlt commented 1 year ago

For some reason, they are called differently when I load the capture file. But I just checked the data fragment (e.g. Data Fragment: c00e010100000000) and they are exactly what you get in the "Unit 6 control 0x1" thing.

soyersoyer commented 1 year ago

Ah, okey :)

So the noise reduction values in changing order: c00e020000000000 c00e010100000000 c00e020100000000 c00e010100000000 c00e020100000000 c00e010000000000 c00e010100000000 c00e020100000000

I assume 2D_NR_OFF = c00e020000000000 2D_NR_ON = c00e020100000000 3D_NR_OFF = c00e010000000000 3D_NR_ON = c00e010100000000

I only need an extension unit guid to reliably get the bUnitID from the code. This can get from lsusb -v -d 1532:0E08|grep -B 2 guidExtensionCode

The preview resolution changes should work without any modification. It shouldn't use these control things.

pohlt commented 1 year ago
❯ lsusb -v -d 1532:0E08 | grep -B 2 guidExtensionCode
Couldn't open device, some information will be missing
        bDescriptorSubtype      6 (EXTENSION_UNIT)
        bUnitID                 2
        guidExtensionCode         {2c49d16a-32b8-4485-3ea8-643a152362f2}
--
        bDescriptorSubtype      6 (EXTENSION_UNIT)
        bUnitID                 6
        guidExtensionCode         {23e49ed0-1178-4f31-ae52-d2fb8a8d3b48}
soyersoyer commented 1 year ago

Same as Kiyo Pro. I've created a branch . Could you try it?

pohlt commented 1 year ago

Works! I can't tell the difference for 2D NR on/off (it's the same with Synapse), but turning 3D NR on/off is very obvious. Awesome! Thanks a lot!

I'll let you know when I have more captures.

pohlt commented 1 year ago

Exposure - Auto Mode

Metering

Compensation

The range is -3 - 3 for Average and _Center. The range is -1 to 3 for Face.

Synapse also offers the values in between (e.g. -2.9), but the sent value is rounded to one of the values listed above (e.g. cc00e0502). We could try to send the values in between (e.g. c00e050_1_00000000, but YMMV).

Exposure - Manual Mode

ISO Value

Shutter Speed

If you remove the trailing "00" byte, the last three bytes give you the shutter speed in µs. Example: 0x01f4 = 500 µs = 1/2000 s

pohlt commented 1 year ago

Focus - Auto

Mode

Tracking:

Lighting Type

Image

Mirror Video

pohlt commented 1 year ago

Lens Distortion

Same settings (like this one) need the camera to be restarted to show their effect.

soyersoyer commented 1 year ago

Shutter speed is interesting, there is UVC control for that. Doesn't it use the V4L2_CID_EXPOSURE_ABSOLUTE (CT_EXPOSURE_TIME_ABSOLUTE_CONTROL)? Could you post the output of the ./cameractrls.py -l?

soyersoyer commented 1 year ago

I've added the new controls to kiyoproultra.

pohlt commented 1 year ago

Shutter speed is interesting, there is UVC control for that. Doesn't it use the V4L2_CID_EXPOSURE_ABSOLUTE (CT_EXPOSURE_TIME_ABSOLUTE_CONTROL)? Could you post the output of the ./cameractrls.py -l?

❯ python cameractrls.py  -l
Basic / Crop
 zoom_absolute = 150    ( default: 110 min: 100 max: 400 )
 pan_absolute = 0       ( default: 0 min: -36000 max: 36000 step: 3600 )
 tilt_absolute = 0      ( default: 0 min: -36000 max: 36000 step: 3600 )
Basic / Focus
 focus_automatic_continuous = 0 ( default: 1 min: 0 max: 1 )
 focus_absolute = 115   ( default: 1 min: 1 max: 450 )
Exposure / Exposure
 auto_exposure = manual_mode    ( default: aperture_priority_mode values: manual_mode, aperture_priority_mode )
 exposure_time_absolute = 156   ( default: 156 min: 3 max: 2047 )
 exposure_dynamic_framerate = 1 ( default: 0 min: 0 max: 1 )
 gain = 29      ( default: 0 min: 0 max: 255 )
Exposure / Dynamic Range
 backlight_compensation = 1     ( default: 0 min: 0 max: 1 )
Color / Balance
 white_balance_automatic = 0    ( default: 1 min: 0 max: 1 )
 white_balance_temperature = 3490       ( default: 5000 min: 2800 max: 7500 step: 10 )
Color / Color
 brightness = 128       ( default: 128 min: 0 max: 255 )
 contrast = 128 ( default: 128 min: 0 max: 255 )
 saturation = 128       ( default: 128 min: 0 max: 255 )
 sharpness = 128        ( default: 128 min: 0 max: 255 )
Advanced / Power Line
 power_line_frequency = 50_hz   ( default: 60_hz values: disabled, 50_hz, 60_hz )
Advanced / Processing
 kiyo_pro_ultra_nr_2d = None    ( values: off, on )
 kiyo_pro_ultra_nr_3d = None    ( values: off, on )
Advanced / Other
 kiyo_pro_ultra_distortion_correction = None    ( values: off, on )
Capture / Capture
 pixelformat = NV12     ( values: YUYV, MJPG, H264, NV12 )
 resolution = 640x480   ( values: 640x480, 640x360, 1280x720, 1920x1080, 2560x1440, 3840x2160 )
 fps = 30       ( values: 60, 30, 24, 20, 15, 10, 5 )
Capture / Info
 card = Razer Kiyo Pro Ultra
 driver = uvcvideo
 path = /dev/video0
 real_path = /dev/video0
Settings / Save
 systemd_save           ( buttons: save )
pohlt commented 1 year ago

There's still some HDR stuff missing, but we've covered about 90% now I guess. 🥳 This is great. Thanks a lot!

One thing I don't understand: The automatic white balance is way too warm. I always have to set it manually to about 4500 to not look like I'm sitting in front of a crackling bonfire. AWB works fine in Win 11. 🤔

soyersoyer commented 1 year ago

It is interesting, that it has an H264 encoder, but the specification page doesn't mention it. The specs says it has 82°- 72° field of view. Does it have a control for it in Synapse? Or only 640x480 has 72° FoV? Could you post the output of the v4l2-ctl --list-formats-ext?

What happens if you change the exposure_time_absolute? Does it have the same effect as shutter speed? (the former is in 100 µs)

The nonfunctional AWB is interesting. Does it work outside Synapse in Win?

soyersoyer commented 1 year ago

The FoV is 72° with Lens distortion compensation, without 82°. The manual says, Synapse has a save button. Could you capture it? The exposure_time_absolute is in 100µs, but I think they want 1µs precision (closer to 1/60s), so we also have a shutter speed control. What is the shutter speed value at 1/60? (16666 or 16667)

pohlt commented 1 year ago

Could you post the output of the v4l2-ctl --list-formats-ext?

❯ v4l2-ctl --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
        Type: Video Capture

        [0]: 'YUYV' (YUYV 4:2:2)
                Size: Discrete 640x480
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
                        Interval: Discrete 0.067s (15.000 fps)
                        Interval: Discrete 0.100s (10.000 fps)
                        Interval: Discrete 0.200s (5.000 fps)
                Size: Discrete 640x360
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
                        Interval: Discrete 0.067s (15.000 fps)
                        Interval: Discrete 0.100s (10.000 fps)
                        Interval: Discrete 0.200s (5.000 fps)
                Size: Discrete 1280x720
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
                        Interval: Discrete 0.067s (15.000 fps)
                        Interval: Discrete 0.100s (10.000 fps)
                        Interval: Discrete 0.200s (5.000 fps)
                Size: Discrete 1920x1080
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
                        Interval: Discrete 0.067s (15.000 fps)
                        Interval: Discrete 0.100s (10.000 fps)
                        Interval: Discrete 0.200s (5.000 fps)
        [1]: 'MJPG' (Motion-JPEG, compressed)
                Size: Discrete 640x480
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
                        Interval: Discrete 0.067s (15.000 fps)
                        Interval: Discrete 0.100s (10.000 fps)
                        Interval: Discrete 0.200s (5.000 fps)
                Size: Discrete 640x360
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
                        Interval: Discrete 0.067s (15.000 fps)
                        Interval: Discrete 0.100s (10.000 fps)
                        Interval: Discrete 0.200s (5.000 fps)
                Size: Discrete 1280x720
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
                        Interval: Discrete 0.067s (15.000 fps)
                        Interval: Discrete 0.100s (10.000 fps)
                        Interval: Discrete 0.200s (5.000 fps)
                Size: Discrete 1920x1080
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
                        Interval: Discrete 0.067s (15.000 fps)
                        Interval: Discrete 0.100s (10.000 fps)
                        Interval: Discrete 0.200s (5.000 fps)
                Size: Discrete 2560x1440
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
                        Interval: Discrete 0.067s (15.000 fps)
                        Interval: Discrete 0.100s (10.000 fps)
                        Interval: Discrete 0.200s (5.000 fps)
                Size: Discrete 3840x2160
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
                        Interval: Discrete 0.067s (15.000 fps)
                        Interval: Discrete 0.100s (10.000 fps)
                        Interval: Discrete 0.200s (5.000 fps)
        [2]: 'H264' (H.264, compressed)
                Size: Discrete 640x480
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
                        Interval: Discrete 0.067s (15.000 fps)
                        Interval: Discrete 0.100s (10.000 fps)
                        Interval: Discrete 0.200s (5.000 fps)
                Size: Discrete 640x360
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
                        Interval: Discrete 0.067s (15.000 fps)
                        Interval: Discrete 0.100s (10.000 fps)
                        Interval: Discrete 0.200s (5.000 fps)
                Size: Discrete 1280x720
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
                        Interval: Discrete 0.067s (15.000 fps)
                        Interval: Discrete 0.100s (10.000 fps)
                        Interval: Discrete 0.200s (5.000 fps)
                Size: Discrete 1920x1080
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
                        Interval: Discrete 0.067s (15.000 fps)
                        Interval: Discrete 0.100s (10.000 fps)
                        Interval: Discrete 0.200s (5.000 fps)
        [3]: 'NV12' (Y/UV 4:2:0)
                Size: Discrete 640x480
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
                        Interval: Discrete 0.067s (15.000 fps)
                        Interval: Discrete 0.100s (10.000 fps)
                        Interval: Discrete 0.200s (5.000 fps)
                Size: Discrete 640x360
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
                        Interval: Discrete 0.067s (15.000 fps)
                        Interval: Discrete 0.100s (10.000 fps)
                        Interval: Discrete 0.200s (5.000 fps)
                Size: Discrete 1280x720
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
                        Interval: Discrete 0.067s (15.000 fps)
                        Interval: Discrete 0.100s (10.000 fps)
                        Interval: Discrete 0.200s (5.000 fps)
                Size: Discrete 1920x1080
                        Interval: Discrete 0.017s (60.000 fps)
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
                        Interval: Discrete 0.067s (15.000 fps)
                        Interval: Discrete 0.100s (10.000 fps)
                        Interval: Discrete 0.200s (5.000 fps)
                Size: Discrete 2560x1440
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
                        Interval: Discrete 0.067s (15.000 fps)
                        Interval: Discrete 0.100s (10.000 fps)
                        Interval: Discrete 0.200s (5.000 fps)
                Size: Discrete 3840x2160
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
                        Interval: Discrete 0.067s (15.000 fps)
                        Interval: Discrete 0.100s (10.000 fps)
                        Interval: Discrete 0.200s (5.000 fps)

pohlt commented 1 year ago

The exposure time setting is weird:

The shutter time setting behaves much more predictable and as expected.

The two settings seem to influence each other:

pohlt commented 1 year ago

What is the shutter speed value at 1/60? (16666 or 16667)

It's 16666.

soyersoyer commented 1 year ago

I've added a better slider for the shutter speed.

pohlt commented 1 year ago

Save seems to be c003a80000000000. Right before the save, there's a c0090a0000000000.

Even if I don't change anything, there are often c009060000000000 and c009080000000000 in the mix.

soyersoyer commented 1 year ago

Save added. Do they return anything? There is a query if the control parameter is 0x02, (not 0x01).

Bleuzen commented 1 year ago

Hi, what is the current state of this? Any help needed?

pohlt commented 1 year ago

I'm currently too busy to contribute so if you own a Kiyo feel free to fill in the gaps. There is some basic support, though.

soyersoyer commented 1 year ago

Did the save work?