Usability For Recording Video In Background Using CameraX API.

81 views
Skip to first unread message
Assigned to tonyt...@google.com by wuj...@google.com

Subhankar Ghosh

unread,
Aug 1, 2023, 12:27:34 PMAug 1
to Android CameraX Discussion Group
Hello All,

I am very much eager to know that, can we use CameraX API for background video recording purposes into Android App? Because I couldn't able to add the CameraX PreviewView without a XML page. Use case of my Android App is to continue the recording video in background even App is killed or device screen is locked scenario also. 

Anyone kindly help me out on that..

tonyt...@google.com

unread,
Aug 16, 2023, 4:26:10 AMAug 16
to Android CameraX Discussion Group, subhank...@tcgdigital.com
You may bind the use cases to a LifecycleService. Here is a SO post about the topic.

Subhankar Ghosh

unread,
Aug 18, 2023, 5:07:53 AMAug 18
to Android CameraX Discussion Group, tonyt...@google.com, Subhankar Ghosh
Thanks for your response. Based on your suggestion I have implemented Background Video Recording using LifecycleService. Also tested in MotoG9 Power Android 11 device and One Plus Nord CE3 Android 13 device, it works fine. But the file size is too big like 02 min 56 secs video size is 134 MB in 320x240 camera resolution. To avoid this large single file scenario I would like to split the video recording in multiple .mp4 files instead of a single .mp4 file. 

I have used CountDownTimer class to automatically start & stop the video recording. To auto stop the Video recording automatically I have implemented videoCapture.stopRecording(); and it works fine, recording stopped & file is getting saved properly but the video recording not again getting starting automatically.

Can you please help me out on this..
Reply all
Reply to author
Forward
0 new messages