KillerInk / FreeDcam

FreeDcam is a CameraApp for Android >4.0(ics) wich try to enable stuff that is forgotten by the manufacturs
GNU General Public License v2.0
297 stars 44 forks source link

underexpose on tap to focus while recording video #74

Closed aunqur closed 3 years ago

aunqur commented 5 years ago

Phone Model: MI A1

FreeDcam Version: 4.1final

Problem Description:

Start recording a video then if I tap to focus, it will down the exposure and scene gets darker. After that every time I focus it is back to the normal exposure mode.

it seems after start the video then first tap to focus triggers something to underexpose the scene.

It was ok on 4.1beta9

Sample: https://drive.google.com/file/d/1w5BHMK8qtGqphm9hPXOcKxnc5tS1DGwV/view?usp=drivesdk

My Settings: Video Profile Frame rate: 25 Shutter: 25 ISO: auto WB: auto EXPCOMP: 0 Contrast: 1 ( may seems video is bright in normal exposure but that is the correct one ) Brightness: 0 Saturation: 5 Sharpness: 0

KillerInk commented 5 years ago

im not sure, non of my devices have that behavior. i could have something todo with the metering, and when the recording starts the mediarecorder takes over the control and may decide to use a different metering.

on most devices with deactivated zsl the preview ignores the shutter speed and iso with active ae. the preview has there only the need to show a bright picture equal if its noise aslong its able to focus and the user see the scene he/she is capturing. with starting a recording the media recorder takes control over the ae and set a fix framerate/shutterspeed. if the preview used now and different speed then the 25fps it may take a few frames till the new iso value is correct measured

aunqur commented 5 years ago

I've tried various settings zsl on/off rdi on/off nothing happens. it is more visible in low light situations but also it flicks quickly first time focus after start recording a video in properly lit environment. may be there is some video parameters set on first focus after start recording.

KillerInk commented 5 years ago

when i remember correct the google camera1 sample creates direct ,with starting the preview, the mediarecorder and prepare it. due that the preview is already controlled by the mediarecorder. freedcam approach is there different. the mediarecorder gets created and prepared on recording start and then take over the control. in low light conditions it could then happen that the preview runs with lower shutter speed then the recorder need. lets say preview use 1/2 sec and recorder want 1/30 for 30fps. in that case it can take several frames till the camera adjusted the shutterspeed to 1/30 and thats what you see as flickering.

the main problem was/is that each time you prepare a mediarecorder you must pass a filepath to it. that create each time a new file also if you are not recording. so you have to track if a user started a recording, and if not you have to delete that empty file.

aunqur commented 5 years ago

But this was ok on 4.1beta9. there might be something triggered on first focus while recording video. Here I've shared a clip of video recording on latest build:

4.1final: https://drive.google.com/file/d/1-5rkMnpF2itp6xVJ_hrBO8Zj8cKPMCal/view?usp=drivesdk

Also see the old app 4.1beta9: https://drive.google.com/file/d/1-IU5rVOiaFANe9jfTJBjxBqaFvgV6rcL/view?usp=drivesdk

4.1beta9 screen recording: https://drive.google.com/file/d/1-F2JpaYtzpBMxYr4BDax70u3HPo5eNe6/view?usp=drivesdk

You can see the difference while tap to focus. On focus event the camera will slightly defocus and then focus.

I am recording with 2 different build on same device and same settings.

aunqur commented 5 years ago

I've investigated the Camera parameters before and after focus start. everything is same. only change is "touch-aec" on and "touch-index-af". I've tried without setting "touch-aec" but same result.

so i've deep down to video recording start call "recorder.start();" at freed/cam/apis/camera1/modules/AbstractVideoModule.java and checked the camera parameters. If I set the Camera parameters before the recorder.start() nothing happens and same result. but If i set video parameters immediately after recorder.start() it resolves the issue. I had to set "cameraUiWrapper.getParameterHandler().SetParameters();" two times as first call will under expose and 2nd call will make it normal.

Now if I tap to focus previous issue is gone and Exposure remains same on every tap of focus. It is really strange to me as I don't know the full project.

Updates: #75

May be some new parameters are causing this problem that is not available in 4.1beta9.

KillerInk commented 5 years ago

you can dump parameters like this.

https://github.com/KillerInk/FreeDcam/blob/b193b29900e0d3b5c95b43399835645455f8ca3d/app/src/main/java/freed/cam/ui/themesample/settings/childs/SettingsChildMenuSaveCamParams.java#L131-L133

its not only strange for you, i dont see the problem. also no new parameters are added to camera1.

what happen when you touch to focus bevor you start recording?

KillerInk commented 5 years ago

on left side in camera ui you see AE. what happen when you change it fromframe-avarage to center-weighted orspot-metering?

aunqur commented 5 years ago

Before recording start there is no effect on touch focus. Exposure remains same as it should be.

Ive changed various AE mode it is working expected before recording.

Only it happens after video recording start. Strange thing is if i lock the exposure before start recording it also change exposure after first focus.

I'll cross check parameters with previous version. May be there is some parameters miss match.

KillerInk commented 5 years ago

i dont think you will find a difference in the parameters between the versions. as said, it works on p9, nexus5, lg g3, sammy s6/7 and good old optimus3d and evo3d.

you can try to disable the qcom focus, maybe its something wrong with.

https://github.com/KillerInk/FreeDcam/blob/b193b29900e0d3b5c95b43399835645455f8ca3d/app/src/main/java/freed/cam/apis/camera1/parameters/ParametersHandler.java#L499-L501

aunqur commented 5 years ago

I've checked with only setAndroidFocus(focusAreas); but the result is same. It happens on first SetParametersToCamera(cameraParameters); after start video record.