Click here to Skip to main content
12,401,173 members (62,212 online)
Click here to Skip to main content
Add your own
alternative version

Stats

39.7K views
45 bookmarked
Posted

Use Android Phone as Webcam and Surveillance Camera

, 4 Jul 2014 CPOL
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.

http://www.twit88.com
http://www.mymobkit.com
http://www.makemoneywithmyapps.com/
http://www.twit88.com/blog

You may also be interested in...

Comments and Discussions

 
QuestionIs it the case that this APP can only operate on the same network between the phone and the computer? Pin
Member 1257898211-Jun-16 22:45
memberMember 1257898211-Jun-16 22:45 
QuestionConnect with 4g Pin
Member 1003483211-Aug-15 7:40
memberMember 1003483211-Aug-15 7:40 
AnswerRe: Connect with 4g Pin
twit8811-Aug-15 16:28
membertwit8811-Aug-15 16:28 
QuestionReg Issue in app Pin
Member 111342806-Oct-14 20:35
memberMember 111342806-Oct-14 20:35 
QuestionSource Pin
link1112-Sep-14 7:55
memberlink1112-Sep-14 7:55 
AnswerRe: Source Pin
twit882-Sep-14 23:32
membertwit882-Sep-14 23:32 
QuestionAwesome idea and ... Pin
Afzaal Ahmad Zeeshan17-Aug-14 3:03
professionalAfzaal Ahmad Zeeshan17-Aug-14 3:03 
GeneralMy vote of 5 Pin
Mihai MOGA13-Aug-14 3:21
professionalMihai MOGA13-Aug-14 3:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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 | Terms of Use | Mobile
Web02 | 2.8.160721.1 | Last Updated 5 Jul 2014
Article Copyright 2014 by twit88
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid