Click here to Skip to main content
Click here to Skip to main content
Go to top

Use Android Phone as Webcam and Surveillance Camera

, 4 Jul 2014
Rate this:
Please Sign up or sign in to vote.
Android phone as webcam or remote surveillance camera through Skype

Introduction

The article describes how you can use your Android phone as webcam or remote  surveillance camera through Skype or VLC Media Player or any other applications that uses DirectShow API. The Android app used here can be found here and the source code is available here.

Background

If you happen to have more than 1 Android phone and you are thinking of how you can make use of the old Android phone besides selling it, then this article is for you.

Using the App and the Source Code

The Android app that I developed is capable of streaming MJPEG. It uses NanoHttpd and extends it to support motion JPEG.

Whenever a video frame is captured, it is streamed as a series of JPEG images as shown below.

private class VideoStreamingTask extends AsyncTask<datastream, void=""> {
	@Override
	protected Void doInBackground(DataStream... videoStreams) {
		isStreamingVideo = true;
		byte[] data = null;
		while (true) {
			if (!isStreamingVideo)
				break;

			DataStream videoStream = videoStreams[0];
			try {
				OutputStream os = videoStream.getOutputStream();
				if (os != null) {
					data = getSnapshot();
					if (data == null)
						continue;
					os.write(("Content-type: image/jpeg\r\n" +
							"Content-Length: " + data.length +
							"\r\n\r\n").getBytes());
					os.write(data);
					os.write(("\r\n--" + NanoHttpd.MULTIPART_BOUNDARY + "\r\n").getBytes());
					os.flush();
				}
			} catch (IOException e) {
				Log.e(TAG, "[doInBackground] Error writing stream", e);
				break;
			} catch (Exception e) {
				Log.e(TAG, "[doInBackground] General exception", e);
				break;
			}
		}
		return null;
	}

	@Override
	protected void onPostExecute(Void result) {
	}
}


</datastream,>

Look into the Java classes under com.mymobkit.net package you can find the various Java classes that use NanoHttpd to host a web server inside your Android app.

By using the Android app, once you start the control panel, you should be able to access the web interface through Chrome browser. Turn on the surveillance camera and you should be able to view your camera remotely. Click on the Media Information button and you can see the URL for the MJPEG stream.

Image showing URL of web control panel

Control Panel URL

 

Image showing the MJPEG URL

MJPEG URL

 

In order for Skype to use MJPEG, download and install either IP Camera Adapter or IP Camera [JPEG/MJPEG] DirectShow Filter. Below is a screenshot of what you should see in Skype. You should see MJPEG Camera for IP Camera Adapter, or IP Camera [MJPEG/JPEG] for IP Camera [JPEG/MJPEG] DirectShow Filter.

Skype camera

 

Now with the MJPEG url and also make sure the camera is turned on through the web control panel, open up your Skype.

Perform the following steps 

  • click Tools > Options
  • Under Video settings, choose "MPJEG Camera" (I am using IP Camera Adapter)
  • click WebCam settings
  • Paste the MJPEG url into the Camera feed URL text box
  • click Autodetect to make sure the URL is working (make sure the camera is turned on).
  • click OK if everything is fine.

 

Skype webcam settings

 

Change the following configurations to allow Skype to answer video call automatically.

  • click Tools > Options
  • Under Calls, click Call settings
  • Click Show advanced options
  • Tick Answer incoming calls automatically.
  • Tick Start my video automatically when I am in a call

 

 

With all the configurations in place, now is time for you to test. Create another Skype id and login using that id from another machine. In my case, I installed Skype in my tablet, and add the Skype id I used with the Android phone. 

Here is what you should see if you make a video call now.

 

Using VLC Media Player

VLC Media Player also supports network streaming using MJPEG. You can open a network stream and view the video remotely.

VLC media player

 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

twit88
Web Developer
Malaysia Malaysia
A programmer for a long time, and still learning everyday.
 
A supporter for open source solutions, and have written quite a few open source software both in .NET and Java.
 
Homepage
http://twit88.com/home
 
Blog
http://twit88.com/blog

Comments and Discussions

 
QuestionSource Pinmemberlink1112-Sep-14 7:55 
AnswerRe: Source Pinmembertwit882-Sep-14 23:32 
QuestionAwesome idea and ... PinprofessionalAfzaal Ahmad Zeeshan17-Aug-14 3:03 
GeneralMy vote of 5 PinprofessionalMihai MOGA13-Aug-14 3:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 5 Jul 2014
Article Copyright 2014 by twit88
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid