diff options
-rw-r--r-- | README.markdown | 16 | ||||
-rwxr-xr-x | prepare-videochat.sh | 58 |
2 files changed, 74 insertions, 0 deletions
diff --git a/README.markdown b/README.markdown new file mode 100644 index 0000000..b5e12ee --- /dev/null +++ b/README.markdown @@ -0,0 +1,16 @@ +ipwebcam-gst +============ + +This is a very simple shell script which allows Android users to use their phones as a webcam/microphone in Linux. The setup is slightly contrived, though: + +* IP Webcam (on the phone) serves up a MJPEG live video stream and a WAV live audio stream through HTTP (port 8080 by default). +* Port 8080 in the phone is bridged to port 8080 in the computer that the phone is plugged to, using ADB port forwarding. You can use IP Webcam through Wi-Fi, but it's rather choppy, so I wouldn't recommend it. +* From local port 8080, a GStreamer graph takes the MJPEG live video stream and dumps it to a loopback V4L2 device, using [v4l2loopback](https://github.com/umlaeute/v4l2loopback). The audio stream is dumped to a PulseAudio null sink. +* Most videochat software in Linux is compatible with `v4l2loopback`: Skype 2.1 (*not* 2.2, it seems), Cheese, Empathy and the Google Talk video chat plugin should work. +* The monitor source for the null sink can be used as the sound recording device for your videochat application, using `pavucontrol`. + +This project includes `prepare-videochat.sh`, which does all these things, except for switching the recording device for your videochat application. It does open `pavucontrol` as needed, though. The script installs the GStreamer tools and `pavucontrol` if needed, but you will have to compile and install the Android SDK and v4l2loopback by yourself. + +To use this script, simply run it with `./prepare-videochat.sh` and follow instructions. You may have to customize a few variables in the CUSTOMIZATION section before using it, though. + +Disclaimer: the script has only been tested in my local installation of Ubuntu 11.04. I can't really support other distributions, sorry! diff --git a/prepare-videochat.sh b/prepare-videochat.sh new file mode 100755 index 0000000..699730c --- /dev/null +++ b/prepare-videochat.sh @@ -0,0 +1,58 @@ +#!/bin/sh + +# Script for using IP Webcam as a microphone/webcam in Ubuntu 11.04 +# Copyright (C) 2010 Antonio García Domínguez +# Licensed under GPLv3 + +set -e + +### CONFIGURATION START + +# Path to "adb" in the Android SDK +ADB=~/bin/android-sdk-linux_x86/platform-tools/adb + +# IP used by the phone in your wireless network +WIFI_IP=192.168.2.122 + +# Port on which IP Webcam is listening +PORT=8080 + +### CONFIGURATION END + +# Decide whether to connect through USB or through wi-fi +if zenity --question --text "Is the phone plugged to a USB port?"; then + "$ADB" forward tcp:$PORT tcp:$PORT + IP=127.0.0.1 +else + IP=$WIFI_IP +fi + +# Remind the user to open up IP Webcam and start the server +zenity --info --text "Now open IP Webcam in your phone and start the server." + +# Install and open pavucontrol as needed +if ! type pavucontrol; then + zenity --info --text "You don't have pavucontrol. I'll try to install its Ubuntu package." + sudo apt-get install pavucontrol +fi +if ! pgrep pavucontrol; then + zenity --info --text "We will open now pavucontrol. You should leave it open to change the recording device of your video chat program to 'Monitor Null Output'. NOTE: make sure that in 'Output Devices' *all* devices are listed." + pavucontrol & +fi + +# Load null-sink if needed +if !(pactl list | grep -q module-null-sink); then + pactl load-module module-null-sink +fi + +# Start up the required GStreamer graph +if ! type gst-launch; then + zenity --info --text "You don't have gst-launch. I'll try to install its Ubuntu package." + sudo apt-get install gstreamer0.10-tools +fi +gst-launch -v \ + souphttpsrc location="http://$IP:$PORT/videofeed" is_live=true \ + ! jpegdec ! ffmpegcolorspace ! v4l2sink device=/dev/video0 \ + souphttpsrc location="http://$IP:$PORT/audio.wav" is_live=true \ + ! wavparse ! pulsesink device=null + 2>&1 | tee feed.log |