This project is superseded by applications such as Droidcam OBS and many others. IT will remain public for anyone who may want to fork and modify this admittedly weak implemenation of automating the ADB tethering used here.
Use your Android device's camera as webcam over USB instead of WiFi.
This will cover the steps to set up IP Webcam on your device and be able to access it securely.
Simple IP Webcam app recommendation: IP Webcam
- Install ADB for your system if you don't already have it.
- Install Python 3 on your system if you don't already have it (recommended Python 3.6 to 3.8).
- On your device, open up Developer Options (you'll have to enable this if you device is running stock, look up the method for your device).
- Find the option called "USB Debugging" under Developer Options and enable it.
- Connect your device to your PC with a USB cable.
- A popup should appear on your device asking if you trust the connection to
your PC. Check the "Always allow from this computer" box and select "Allow".
- If the prompt does not appear, locate the ADB executable and open a console
or powershell window in that location, then type
adb devices
. This should bring up the prompt and list the devices the ADB program can see.
- If the prompt does not appear, locate the ADB executable and open a console
or powershell window in that location, then type
- In the IP Webcam app, configure your setup and specify a port to use (or stick with the default 8080).
- Set up a username and password in the IP Webcam app, under the "Local broadcasting" section.
- On your PC, open the adb.json file and modify it to point to the adb
executable, as well as put in the port that you specified in the IP Webcam app.
- Example JSON:
{ "location": "C:\\Program Files\\something\\somewhere\\adb.exe", "port": "8080" }
- Open a console or powershell window and navigate to where you keep this repository.
- Run the following command and you should see the program's output:
python adb_handler.py
. - If you do not see any errors, then follow the next set of steps. If you do see any errors, you didn't follow the steps above correctly.
- On your device, IP Webcam should list a URL at the bottom of the screen for you to access.
- For example, if you used port
8080
then the URL might look likehttp://192.168.1.24:8080
- Open up that URL in a browser on your PC. It will ask for the username and
password you set previously, and you'll be met with a page containing a lot of
options for controlling your phone's camera.
- If you wish to preview the video, select from the different "Video renderer" options listed at the top of the page. "Browser" usually works for me.
- Confirm that your camera works correctly on this webpage.
- To use your camera with OBS, create a new Browser Source and use the URL
you got to connect to the IP Webcam browser page, use the following format to
access it:
- For example, with the normal URL of
http://192.168.1.24:8080
the Browser Source URL should behttp://username:[email protected]:8080/video
. - Note that the username and password are used here, and they are completely visible when the Browser Source's properties are visible.
- For example, with the normal URL of
Voila, you're done!
ISSUES:
- IP Webcam does not work in OBS as a Browser Source when using HTTPS URL's.
- SOLUTION: Use the regular HTTP version of the URL instead of HTTPS.