pedroSG94 / RootEncoder

RootEncoder for Android (rtmp-rtsp-stream-client-java) is a stream encoder to push video/audio to media servers using protocols RTMP, RTSP, SRT and UDP with all code written in Java/Kotlin
Apache License 2.0
2.57k stars 776 forks source link

How to use torch/flash when recording #1608

Closed NerdySouth closed 1 month ago

NerdySouth commented 1 month ago

Hi, I have an app that uses your library, and would like to be able to blink/toggle the flash of my device whenever i start recording. Currently, the app uses a StreamBase to initiate an RTMP stream using a Camera2Source object. I have tried calling enableLantern() on the Camera2Source before passing it to prepareVideo(), but after that what more should i do? This does not seem to activate the flash LED. I have confirmed i can control the flash LED when the camera is not in use by RootEncoder, but i need to be able to access it while the stream is happening via RootEncoder. Any ideas? Would be happy to add the necessary code if i have to.

pedroSG94 commented 1 month ago

Hello,

enableLantern method should be called after start stream, record or preview. If you do it before that, that method is ignored: https://github.com/pedroSG94/RootEncoder/blob/master/encoder/src/main/java/com/pedro/encoder/input/sources/video/Camera2Source.kt#L121

Remember that you need android flash permissions:

<uses-permission android:name="android.permission.FLASHLIGHT" />
NerdySouth commented 1 month ago

This worked well, thank you!