-
-
Notifications
You must be signed in to change notification settings - Fork 728
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
Video Recording implementation using CameraX lib #419
base: master
Are you sure you want to change the base?
Conversation
- destroy() releases the camera resource unlike close() which just stops the preview Signed-off-by: Arka Prava Basu <[email protected]>
- setting LifecycleOwner will remove boilerplate around open(), close() and destroy() - a possible fix for guardianproject#376 ? Signed-off-by: Arka Prava Basu <[email protected]>
- holding this reference may lead to Context leak Signed-off-by: Arka Prava Basu <[email protected]>
Signed-off-by: Arka Prava Basu <[email protected]>
- keeping Context (Activity/Fragment) in a singleton will cause memory leaks Keep the global application object associated with it instead - fix guardianproject#399 Signed-off-by: Arka Prava Basu <[email protected]>
Signed-off-by: Arka Prava Basu <[email protected]>
- Among others this updates materialdatetimepicker to 4.2.0 which fixes a memory leak Signed-off-by: Arka Prava Basu <[email protected]>
- keep this app dependency free; can be added in debug builds whenever another investigation is required Signed-off-by: Arka Prava Basu <[email protected]>
…anary Signed-off-by: Arka Prava Basu <[email protected]>
Signed-off-by: Arka Prava Basu <[email protected]>
Signed-off-by: Arka Prava Basu <[email protected]>
- aims to solve guardianproject#395 (comment) - According to https://developer.android.com/reference/androidx/lifecycle/DefaultLifecycleObserver [DefaultLifecycleObserver] should *always* be preferred over [androidx.lifecycle.LifecycleObserver] if we use Java 8. [CameraView] library targets Java 7 hence this implementation aims to ignore [androidx.lifecycle.OnLifecycleEvent] annotated methods in the super class and replace them with the callbacks implemeted in this sub class Signed-off-by: Arka Prava Basu <[email protected]>
Signed-off-by: Arka Prava Basu <[email protected]>
- due to camerax preview lib we need to make minSDK to 21 from 16; if this is going to be a major problem we may need to go ahead without the preview lib Signed-off-by: Arka Prava Basu <[email protected]>
Signed-off-by: Arka Prava Basu <[email protected]>
Signed-off-by: Arka Prava Basu <[email protected]>
- Use PreviewView instead of CameraView - MotionAnalyser as the image analysis Use Case to work with MotionDetector to detct motion - save image on motion detect and notify running service - Expose LiveData from MotionDetector for result; alternative to callbacks Signed-off-by: Arka Prava Basu <[email protected]>
Signed-off-by: Arka Prava Basu <[email protected]>
Signed-off-by: Arka Prava Basu <[email protected]>
- current implementation does not allow both image and video capture simultaneously Signed-off-by: Arka Prava Basu <[email protected]>
Signed-off-by: Arka Prava Basu <[email protected]>
- stop monitoring via a message to service instead of invoking from outside - close the activity after a delay of 3s to clean up video capture and image capture Signed-off-by: Arka Prava Basu <[email protected]>
Signed-off-by: Arka Prava Basu <[email protected]>
Signed-off-by: Arka Prava Basu <[email protected]>
- listen on a live data of result instead of events - string formatting Signed-off-by: Arka Prava Basu <[email protected]>
Signed-off-by: Arka Prava Basu <[email protected]>
Signed-off-by: Arka Prava Basu <[email protected]>
Signed-off-by: Arka Prava Basu <[email protected]>
- Keep switch in preference to toggle simultaneous video monitoring - when on along with video monitoring both image and video will be captured; this will stop camera preview - when off but video monitoring on only video will be captured for the camera events and we will have image preview - video monitoring off will keep only image capture on Signed-off-by: Arka Prava Basu <[email protected]>
- Copy image helper from cameraview lib Signed-off-by: Arka Prava Basu <[email protected]>
Awesome! This might solve more issues than those two, I'm seeing a stable experience on 5.1 and that's never happened, ever. I'll test this using legacy and flagship devices/ simulators & lend feedback. Testing some UI and onboarding changes yesterday, this library is what we needed:
|
More fantastic work. This is the direction I had hoped to be able to head, and glad to see CameraX provides what we need. |
Getting this error on Pixel 3A, Android 10 E/CameraFragment: Use case binding failed |
Seems like there was an issue reported here: android/camera-samples#38 |
btw, this is with "Simultaneous Image Monitoring" disabled |
and found a blog post about this limitation here: |
I think this can be fixed by removing lines 43 & 44 from MediaRecorderTask- unlocking the camera was causing this for me on lower builds. Give it a go if you please. Removed:
|
Was able to reproduce. More as I debug. |
Checking in with new camera implementation. Some calls don't play well with CameraX, SDK dependent. Performing only simple updates to deprecated camera methods has it working on AOS 5.1 and above.
Thanks for pushing this, Archie. I appreciate your hard work. |
Really appreciate all the testing. Will try hard to get into this the coming weekend. |
To reiterate. CameraView also uses native hardware encoding and #434 enables this. I'll look into this CameraX branch a little, too. |
@archie94 are you available at all to rebase these changes in a way that would make it clearer and easier for others to take up the mantle of getting it stable? Or separate stable ones out so they can be merged? |
@xloem - Appreciate your work; the camera implementation was my first issue a few years back with this project.. so it seems we need some help getting it stable 🤝 - I’ll make a pseudo-master branch of your changes to see how they interact with updated Google/third party libs & deps |
Sorry for the inactivity here, my job has kept me pretty busy! @xloem I am open to resolving the conflict, which looks trivial. Do you need a rebase specifically? As such the commit history on this branch looks self explanatory to me. Apart from that it looks like we need to have a few checks on the device camera characteristics before enabling Preview, analysis, image capture and video capture all at once. Initially I thought the first 3 would be always supported and the 4th can be optional but clearly some devices would not allow that. A little busy right now to dig deeper at this moment but definitely will look into it as I have the time. |
It's just a lot of changes to review to understand where the code is at. Some of them look squashable or technically unnecessary at a quick glance. The less noise there is to the information, the more visits and visitors pass the time thresholds to contribute. Any explanation is helpful. Thanks so much for your update. |
Signed-off-by: Arka Prava Basu <[email protected]> Update dependencies Signed-off-by: Arka Prava Basu <[email protected]>
Signed-off-by: Arka Prava Basu <[email protected]>
Signed-off-by: Arka Prava Basu <[email protected]>
The primary objective of this PR is to solve #360 #413
We are using the camerax library instead of the camera view library we have been using. CameraX will use the native Hardware encoding to record videos which should provide us better quality of output and possible improvement to stability.
Implementation details:
Cons:
Testing is always appreciated, better across a wide range of devices since we are dealing with the camera layer. Please leave comments/bugs/suggestions here.
Thanks!