Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: camera optical zoom support #4452

Open
1 task done
rektide opened this issue Nov 23, 2023 · 11 comments
Open
1 task done

Request: camera optical zoom support #4452

rektide opened this issue Nov 23, 2023 · 11 comments

Comments

@rektide
Copy link

rektide commented Nov 23, 2023

Is your feature request related to a problem? Please describe.
This is a feature request! I'd love to be able to use the optical zoom on my cameras when doing --video-source=camera!

Describe the solution you'd like
--camera-zoom 1.5 would ideally zoom to 1.5x, in my view.

Describe alternatives you've considered
I don't know? It'd be neat to be able to change the zoom live. I don't know if scrcpy has any other properties that are potentially dynamic like this?

One wild alternative would be to build a camera app that exposes a way to zoom and to stream the phone output, rather than a video camera. This feels like it would have more latency & overhead, & would require some app dev.

Additional context
Now that we can stream cameras, there's a host of various video settings that would be nice to be able to tune. Maybe there's some android app that can help us do this? Things like contrast, exposure compensation, color balance, even ideally things like having LUTs or log-output control would be incredible to add, especially if we can dynamically adjust some of these settings.

@rektide rektide changed the title Optical zoom support Camera optical zoom support Nov 23, 2023
@rektide rektide changed the title Camera optical zoom support Request: camera optical zoom support Nov 23, 2023
@rom1v
Copy link
Collaborator

rom1v commented Nov 23, 2023

--camera-zoom 1.5 would ideally zoom to 1.5x, in my view.

Yes, technically it's possible.

It'd be neat to be able to change the zoom live.

Yes. It will require some changes in the control code, because currently controls are disabled when video source is camera (as if --no-control was passed)..

@stranno
Copy link

stranno commented Jan 13, 2024

Other camera "PRO" features would be great as well, like focus, exposure and such. I don't know how many camera features are exposed though.

@whatupjeff
Copy link

Most phones accomplish optical zoom with separate cameras. The Pixel 8 Pro has three rear cameras, each with its own lens and and sensor. I wonder if its possible to have them return separate camera-id's.

I would want to select the lens being used instead of relying on a continuous camera-zoom parameter and allowing the phone to determine the camera.

@rom1v
Copy link
Collaborator

rom1v commented Jan 19, 2024

@whatupjeff You might be interested in the whole discussion about physical/logical cameras here: #4392 (comment) (and further comments).

@christopher317
Copy link

christopher317 commented Feb 9, 2024

speaking of zoom, i was wondering if it was possible to switch witch lens was being used to the wide angle lens in my case or the telephoto lens ( not necessarily on the fly )

edit: wait hang on i think thats what jeff asked
edit2:
would it still be possible to list all of the cameras on the device ( eg wide angle and other ones ) instead of just the main front and back cams?

@sortedcord
Copy link

Other camera "PRO" features would be great as well, like focus, exposure and such. I don't know how many camera features are exposed though.

Has anyone else looked into it? Iirc the other day when I was going through the api documentation, there was a mention of an endpoint that allowed you to choose an auto-exposure & antibanding mode from the profiles available...

@Glebsin
Copy link

Glebsin commented Feb 16, 2024

Has anyone else looked into it? Iirc the other day when I was going through the api documentation, there was a mention of an endpoint that allowed you to choose an auto-exposure & antibanding mode from the profiles available...

@sortedcord Please let me know if you found a solution

@Glebsin
Copy link

Glebsin commented Feb 18, 2024

@rom1v Sorry for the ping, but what are the chances of manual exposure and autofocus control coming soon ?

@rom1v
Copy link
Collaborator

rom1v commented Feb 18, 2024

what are the chances of manual exposure and autofocus control coming soon ?

I don't plan to implement them soon. There are other things to work on.

@Disonantemus
Copy link

Disonantemus commented Feb 29, 2024

@rom1v Sorry for the ping, but what are the chances of manual exposure and autofocus control coming soon ?

Every smartphone camera has some kind of Auto Focus by default, maybe you want Manual Focus (turn off auto focus), is useful to camera don't get confused at leave things out of focus, some thing like a "locked" focus. I want that. Right now I'm recording my desktop table from above with smartphone with scrcpy, and some times happens this.

Of course I would like a full manual control like Pro Mode in smartphone cameras but maybe it's a niche use. Photography enthusiast here.

Talking about zoom ... I did try crop command with --video-source=camera and didn't work, there is a way to do that? or zoom in? Mod+g (1:1 mode) didn't work in dwm (tiling window manager), I needed to set scrcpy to floating mode.

@Vixeliz
Copy link

Vixeliz commented Oct 25, 2024

I needed to be able to lock exposure and such manually for my usecase. I don't know if ill make this actually usable via cli options and such since I basically never need them changed but if anyone is in a similar boat and doesnt mind changing source code here is the change I made (in server/src/main/java/com/genymobile/scrcpy/video/CameraCapture.java:

    private CaptureRequest createCaptureRequest(Surface surface) throws CameraAccessException {
        CaptureRequest.Builder requestBuilder = cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_RECORD);
        requestBuilder.addTarget(surface);
        
        // Have to turn this off to be able to control ae, awb, and af separately from what I can tell. 
        requestBuilder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_OFF);
        // Turn off auto exposure
        requestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_OFF);
        // Handle white balance automatically
        requestBuilder.set(CaptureRequest.CONTROL_AWB_MODE,
                CaptureRequest.CONTROL_AWB_MODE_AUTO);
        // Auto focus on auto
        requestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_VIDEO);

        // Setting sensor sensitivity this is basically iso 
        requestBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, 150);

        // Setting sensor exposure time this and frame duration are in nano seconds. So this would be roughly 1/60th of a second
        requestBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, 16000000L);
        
        // Frame rate im pretty sure so this is roughly 1/30th of a second or 30fps :P
        requestBuilder.set(CaptureRequest.SENSOR_FRAME_DURATION, 33000000L);

        if (fps > 0) {
            requestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, new Range<>(fps, fps));
        }

        return requestBuilder.build();
    }

edit: Keep in mind haven't thoroughly tested this but just wanted to put out there. It seems to work for me but your mileage may vary. Some devices also don't support some of these options from what I can tell. Also ranges vary etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants