Skip to content

Instantly share code, notes, and snippets.

@tobi-wan-kenobi
Created April 23, 2020 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobi-wan-kenobi/0294ee14680213c7fa725c48c6d8b33d to your computer and use it in GitHub Desktop.
Save tobi-wan-kenobi/0294ee14680213c7fa725c48c6d8b33d to your computer and use it in GitHub Desktop.
Using Android IP Webcam on Void Linux

Using Android IP Webcam on Void Linux

Motivation

I wanted to use my mobile phone as web cam, because it has a half-way decent camera.

Solution

Inspiration: github:bluezio/ipwebcam-gst

Assumes that you have WiFi on your mobile phone

  1. Install Google Play:IP Webcam on your Android phone
  2. Configure it (pretty straight-forward) and start the server
  3. On your Void Linux machine:
sudo xbps-install -S v4l-utils v4l2loopback gst-plugins-good1
sudo depmod -a
# remember current devices
ls /dev/video*
sudo modprobe v4l2loopback
# this should now show 1 more device - the loopback
ls /dev/video*
# start a gstreamer pipeline piping the live feed into the loopback device
# the flags probably could do with some adjustment...
gst-launch-1.0 souphttpsrc location="http://<mobile phone IP>:<configured port>/videofeed" \
        do-timestamp=true is-live=true ! \
        multipartdemux ! decodebin ! \
        videoflip method=horizontal-flip ! videoconvert ! v4l2sink device=/dev/video2
# better quality:
gst-launch-1.0 souphttpsrc location="http://<mobile phone IP>:<configured port>/videofeed" \
        do-timestamp=true is-live=true ! \
        multipartdemux ! decodebin ! \
        videoflip method=horizontal-flip ! videoconvert ! \
        videoscale ! videorate ! \
        video/x-raw,format=YUY2,width=1280,height=720,framerate=12/1 ! \
        v4l2sink device=/dev/video<N>

Once you've done that, you can simply select /dev/video<N> inside your application (VLC, for example)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment