Adding here as I've been troubleshooting an issue for the past day and eventually found a solution that could help others. (On MacOSX, using Android Studio Emulator)
Problem: When trying to use OBS Studio as a virtual camera for the emulator, the emulator does not recognize the OBS Virtual Camera and the only option in the device manager camera settings is webcam0
which is the built in webcam. AND the camera app on the android emulator does not recognize the virtual camera device.
Solution:
install OBS Studio and run it, start the virtual camera for the first time, this will automatically install a CoreMediaIO DAL plug-in at /Library/CoreMediaIO/Plug-Ins/DAL
and create the virtual webcam device.
go to the emulator folder of your Android Studio installation cd ~/Library/Android/sdk/emulator
and check the available web cam list with the command ./emulator -webcam-list
, you should see two webcams available; the built in camera webcam0
and the obs virtual device webcam1
.
edit the config file for your avd to use webcam1
by opening terminal and running nano ~/.android/avd/{AVD NAME}/config.ini
scroll down and amend the line hw.camera.back = webcam1
Ctrl+O to write out and Ctrl+X to exit nano.
make sure your OBS virtual device is started in the OBS Studio program.
run the emulator through command line specifying the virtual camera by going to the emulator folder cd ~/Library/Android/sdk/emulator
and running ./emulator -avd {AVD NAME} -camera-back webcam1
the device will now boot and when you open the camera app, you should see the OBS virtual device input. IF YOU DO NOT, follow below, as this was my major problem.
If the camera app shows an error and you cannot see the OBS virtual device even after following the above steps, the solution that worked for me is to reset camera access permissions. It turned out for me that the emulator had previously requested access to the camera from the system whilst the built in webcam0
was the camera source for the avd. The emulator needed permission to use the virtual device webcam1
from the system, but would not request it again as it already had permission for the built in camera webcam0
. This caused an error when opening the camera app in the emulator as it could not access the source.
To solve this you must close the emulator and android studio, and run tccutil reset Camera
(note this will reset camera permissions for all applications, you can reset the permissions for only Android Studio/specific applications by running tccutil reset Camera com.WHATEVERBUNDLE.YOURAPPID
.
After resetting the camera permissions, start the emulator again using step 4 above, and when opening the camera app, you should be prompted by the mac system to allow camera access to Android Studio, give it access and then you should see the OBS virtual camera input as expected.
Note: I found after running the emulator through the command line once, you can then run the emulator normally and the camera settings will persist.