Audio disabling in Java

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

Teodor

unread,
Sep 27, 2022, 3:24:19 AM9/27/22
to Android CameraX Discussion Group
Is there a way to disable audio being recorded when capturing a video in Java?

I've gone through such topics, but they are all in Kotlin and I can't really find how to make it work in Java code... 

Also, as I only need a video(without audio) in my application, is there a workaround to use the CameraX API without requesting an audio permission at all.

Any help or a guideline will be appreciated!
Thanks!

tonyt...@google.com

unread,
Sep 27, 2022, 4:54:16 AM9/27/22
to Android CameraX Discussion Group, Teodor
Hi,
The recording won't have audio audio by default, unless PendingRecording.withAudioEnabled is called explicitly. And the audio permission is only required if `withAudioEnabled` is called. So if you start a recording like `recorder.prepareRecording(context, outputOption).start(executor, listener);`, you will get a video-only recording.

Teodor

unread,
Sep 27, 2022, 5:25:00 AM9/27/22
to Android CameraX Discussion Group, tonyt...@google.com, Teodor
Hi there,

Currently, I am using the VideoCapture use case and it is bound to the lifecycle so none of this you mentioned exists in my code. I do have audio enabled by default there, due to the VideoCapture.startRecording(...) method.

If I can completely avoid the audio with this recorder of yours, please do give some more instructions.

Thanks in advance!

tonyt...@google.com

unread,
Sep 27, 2022, 5:56:16 AM9/27/22
to Android CameraX Discussion Group, Teodor, tonyt...@google.com
Ah, sorry for the confusion. Looks like you are using the legacy video capture implementation we had before. And we had released a new implementation (camera-video since version 1.1.0-alpha10) with bunch of new features and fixes and is recommended to use for video feature. Here are the documentation and sample that you may reference to. Please give it a try and let us know if there's any question.

Teodor

unread,
Sep 27, 2022, 10:15:53 AM9/27/22
to Android CameraX Discussion Group, tonyt...@google.com
I've taken the time to go further into this new implementation and it actually works! 

Thanks for the guidelines, mate!

tonyt...@google.com

unread,
Sep 27, 2022, 1:10:57 PM9/27/22
to Android CameraX Discussion Group, Teodor, tonyt...@google.com
Happy to help!
Reply all
Reply to author
Forward
0 new messages