For many users who spend long hours away from home due to work or study, it is important to protect their most precious assets, in many cases achieved with great effort, others simply want to know what is happening in their homes while they are not there to see the behavior of your pets, and for other users it can just be a pretty entertaining project.
In this article we will see how to use an Android smartphone as a webcam to monitor our home, a task for which we will use IP Webcam on the phone and an open source tool like Motion. It is a server that allows us to access the webcam that we have installed on our computers, although it is generally used in conjunction with USB webcams, here we are going to give new life to old Android devices.
To start we are going to install IP Webcam, a tool found available for free from the Play Store so we simply went to the Google application store and downloaded it to our smartphone. We have a few options, but with what comes by default we will be fine so we can tap on the 'Start server' option for the device to start filming, and IP Webcam will indicate the IP address and the port from which it is transmitting, for example 192.168.1.103:8080.
Now we go to our computer and we install Motion, something very simple since it is available in the official repositories of Ubuntu, so we just run:
sudo apt-get install motion
After that we have to edit configuration file, for which we choose our preferred editor (in this case, gedit):
sudo gedit /etc/motion/motion.conf
We are going to see that we have many options, and that is precisely one of the main aspects in favor of this tool is the fact of being able to configure what we come up with. But we leave that for the most expert, we want set up a webcam server in a relatively simple way so we are going to base ourselves more than anything on what interests us, for example defining if we want Motion to start as a daemon, for which we look for the option Daemon and we change the «Off» which comes by default by "we" (without the quotes, of course). We can also modify the connection port, and the framerate that will be used for transmission, something in which you cannot be too specific since it depends on what we need. If we simply want to see what happens, 1 or 2 frames per second (FPS) may be fine but if we need something stricter we may have to set that number at 10 FPS, although we must bear in mind that this will also require a much larger space storage for recordings.
Next, we are going to configure something that in our case is the most important and is the choice of the video input device, for which we go to an option that says "# Videodevice to be used for capturing (default / dev / video0)". In general, those who use a webcam can just leave it in / dev / video0 since it is where a USB webcam is located by default, but in our case we are going to use a Android smartphone so let's add a ";" (semicolon) in front of that option to override it. Now we look for the option that starts with "Netcam_url", and we are going to use the IP address that has been informed to us in IP Webcam when we start the server, so we leave it as follows:
netcam_url http://192.168.1.103:8080/videofeed
Now Motion will use the Android smartphone as the source of the video that it will transmit over the network, but we also have to modify an option that determines if this will be transmitted only to a local computer. Is named 'webcam_localhost', which should be as follows:
webcam_localhost off
Now yes, we can access what our webcam captures, regardless of where we do it from. Of course, for this we must open the ports that Motion uses on our router (We can also modify this from the configuration file) redirecting it to the IP address of the computer that runs it. If we already know our IP address on the internet we can enter it in the address bar of the browser and we will be ready, we will immediately see the feed that our Android smartphone captures; for those who do not master the command line there is a very simple way to find out this address and it is through services like What is my IP?.