LoopyLab

Use android phone as USB webcam for OBS

There are two common known programs to use your android phone as a webcam. The first one is DroidCam, the other one is IP Webcam. DroidCam offers the option to use it over USB, but is limited in the supported options. IP Webcam does only support connections over IP (which equals to WiFi for most smartphones).

The problem with WiFi might be a laggy video feed, when the connection is not very good.

So wouldn’t it be nice to use IP Webcam over a USB connection? The idea is to use adb.exe to forward the port of IP Webcam (normally 8080) to your computer.

HowTo

Okay, so here is a step by step guide:

  1. Enable Developer Mode on your phone and enabled USB debugging. There are a lot of tutorials to do this. For example, follow this one.
  2. Get adb.exe. To get it, you can download the SDK platform tools for windows from here. From that zip you only need adb.exe, AdbWinApi.dll and AdbWinUsbApi.dll. Copy the files in a new directory.
  3. In IP Webcam just scroll down and click on start server. In the new screen you will see a port number right after your IP-Address (like 192.168.178.24:8080).
  4. Open a terminal in the new directory by holding Shift and right click and click on “Open PowerShell Here”.
  5. Type the following command .\adb.exe forward tcp:8081 tcp:8080 to forward the port 8080 from the phone to your computer to port 8081.
  6. In OBS add a browser source and set the following URL: http://localhost:8081/videofeed.

Multiple Webcams

You need multiple webcams and have multiple phones? Follow the steps from above, but when you forward the port, you need to specify the device. You can get all devices to your computer with the command adb.exe devices -l. Now copy the device identifier (something like BH4023468D) and use it in the forwarding command like this: .\adb.exe -s BH4023468D forward tcp:8081 tcp:8080. For the next phone, replace 8081 with 8082, 8083, … and use the new port in another browser source in OBS.

MQTT Dashboard

If you ever develop something with mqtt, you might need a client to send some test messages and view the published messages. To generate a simple dashboard with buttons and subscribers to different topics, a friend of mine and I created a webapp.

The Code can be found on github at https://github.com/DirkHeinke/mqttDashboard and a running demo is here: http://mqttdashboard.dirkheinke.de/

Jekyll, Travis, Docker - permissions denied

After trying to redeploy my blog with travis, the build failed with this message:

[...]
jekyll 3.8.3 | Error:  Permission denied @ dir_s_mkdir - /srv/jekyll/_site

The problem was, that travis set permissions for uid 2000, but the container runs with uid 1000. Adding write permissions to the folder allows jekyll to create a new folder and write the output. My docker run command now looks like this:

docker run --rm --volume=$(pwd):/srv/jekyll jekyll/jekyll /bin/bash -c "chmod a+wx . && jekyll build -V"

WiPy without expansion board

I bought a WiPy 2.0 from pycom and noticed, that the documentation assumes you also bought the expansion board (which I didn’t). The board has some components but most of them are for the SD card support or the LiPo charger. An (older?) version of the board is documented here. What you really need is only some sort of power supply and a USB serial (3.3V). The pinout of the WiPy board is here

I connected a spare ESP8266 programmer to the RX and TX ports and used another USB port for the 5V supply. You can also power the board with 3.3V via the 3.3V pin, but you need at least 500mA (more info).

jekyll, github and travis-ci

The source of this blog is now available at github. Also I’m now using travis-ci to generate the static files and deploy them to my server. Stuff I found out:

travis-ci language

If you use docker to run your commands, the language you specify in the travis.yml file doesn’t really matter.

ssh-key for scp

My deploy script uses scp, so travis needs access to my server. For that, I created a new ssh-key:

ssh-keygen -t rsa -b 4096 -C "Travis CI loopylab" -f travis_loopylab_key

Then added the public part to my server and encrypted the private part with the travis cli:

travis encrypt-file travis_loopylab_key

The newly generated file can be pushed to your repository and no one can readout the key (hopefully).

Now just add the following lines to your travis.yml:

addons:
    ssh_known_hosts: dirkheinke.de
[...]
before_deploy:
    - eval "$(ssh-agent -s)"
    - openssl aes-256-cbc -K ... # use the output of the travis cli
    - chmod 600 /tmp/travis_loopylab_key
    - ssh-add /tmp/travis_loopylab_key

deploy:
    skip_cleanup: true
    provider: script
    script: ./_deploy.sh
    on:
        branch: master

You can find my full travis.yml here

PS: Don’t try to put the private key in a environment variable from travis, because the line breaks are important for ssh.

docker in travis-ci

You can use docker commands in every part of the travis.yml file, even if the documentation only mentions the before_install part.