TryDocFromLibre
Template:Anchor WIRELESS VIDEO STREAMING USING A RASPBERRY PI (SPY-CAM)
The design of the Remote streaming module which enables one to view the video stream of a place remotely using the Raspberry Pi Single board computer SBC is mostly software based. All the hardware components are ready-made peripherals, which are directly attached to the Raspberry Pi and configured for the specific purposes.
Basically, the project can be classified as an Internet of Things (IoT) project. The router is used to link up 2 or more computers either wirelessly or using a LAN (Local Area Network) cable. Viewing the video stream from the local devices which are connected through the LAN is much more easy and straight forward as viewing it from the Internet is. This internet connectivity can be provided to the raspberry pi by a wireless dongle attached to the raspberry pi zero or a LAN cable or a USB 3G dongle. In this project, a USB Wi-Fi adapter is used to provide the raspberry pi zero with internet connectivity.
This project is made up of fundamentally two parts:# The Hardware Part
- The Software Part
The figure 3.1 shows the different blocks that make up the module.
Template:Anchor Template:Anchor 1 Analysis of the Hardware Components
The figure 1 shows the block diagram of the hardware setup of the system:
The different components that make up the module as follows: # Raspberry pi zero: The Raspberry Pi Zero is a full-fledged member of the Raspberry Pi family, featuring the following:
- A Broadcom BCM2835 application processor
- 1GHz ARM11 core (40% faster than Raspberry Pi 1)
- 512MB of LPDDR2 SDRAM
- A micro-SD card slot
- A mini-HDMI socket for 1080p60 video output
- Micro-USB sockets for data and power
- An unpopulated 40-pin GPIO header
- Identical pinout to Model A+/B+/2B
- An unpopulated composite video header
- Our smallest ever form factor, at 65mm x 30mm x 5mm
Raspberry Pi Zero runs Raspbian OS, a Debian distribution. It also runs some Linux applications, including Scratch, Minecraft and Sonic Pi.
- USB Keyboard: The USB keyboard is used as a character input device for the raspberry pi. It is also very useful when the raspberry pi is not running in headless mode.
- USB Hub: The USB Hub is used to provide multiple USB inputs to a single port on the raspberry pi. The USB Hub used for this project is not at active type, i.e. is not a powered USB hub. The Wi-Fi dongle and the USB mic. are attached to the USB hub.
- OTG Cable: The On-The-Go (OTG) cable is used as a converter for the micro USB port present on the raspberry pi to a normal port. The cable is also used as an extension for the peripheral devices attached to the RPi (Raspberry Pi).
- Memory card: This is the hardware which contains the OS (Operating System) running on the raspberry Pi. It is advisable to use at least an 8G Class10 MicroSD Card as the OS takes up to 4 gigabytes on installation. The Class 10 stands for the read and write speed of the memory card.
- The Router: The router is used to provide internet connectivity to the raspberry pi. Though this is not an integral part of this module, it is fundamental for connecting other computers remotely to the same network that the raspberry pi is connected to locally for a situation where the video stream is to be done locally and not over the internet. Template:Anchor
Template:Anchor 2 Software Analysis
The software used to accomplish the objective of this project are as follows:
Template:Anchor Template:Anchor 2.1 The Raspbian Jessie Pixel
This is a Linux distribution which is more of a combination of Debian and Raspberry. It is built specifically to run on the Raspberry Pi. It has a desktop view and also a command line interface.
Template:Anchor Template:Anchor 2.2 The SD Card Formatter
This is a Windows-based software which is used to format the microSD card in which the Raspbian image is going to be mounted on.
Template:Anchor Template:Anchor 2.3 Etcher
This is the software used to write the Raspbian image to the Raspberry Pi microSD card.
Template:Anchor Template:Anchor 2.4 Putty
Putty is a tool that enables one to connect to the command line interface (CLI) of the raspberry pi through a protocol known as SSH (Secure Shell). The raspberry pi and the computer that request access to the raspberry are required to be connected on the same Local Area Network (LAN). Also, the username and password of the raspberry pi to be accessed is needed when trying to login to the raspberry through SSH, using Putty.
Template:Anchor Template:Anchor 2.5 VNC Viewer
This is a Windows-based application that provides a server for viewing the X windows of the raspberry pi
Template:Anchor 2.6 Mjpg-Streamer
This is the fundamental software that is required to run the video stream. It is written in python language and supports the Debian operating system.
Template:Anchor 2.7 WeavedConnect
This is a service which runs on the raspberry pi allowing for the video stream to be accessed from anywhere in the internet without having to port forward a particular port on the router. It is very secure as it requires an account to be created with weaved.com. To allow for remote access the service has to be activate using the account that is created in the weaved.com website and the weavedConnect service has to be activated on the raspberry pi.
Template:Anchor 3 Design Methodology
The following steps are carried out in setting up the raspberry pi zero for live video streaming over the wireless network:* Insert the memory card into a computer and format it using the SD card formatter
- Use etcher to write the Raspbian Jessie Pixel OS image into the microSD card
- After the write process is complete, take out the SD card and mount it on the raspberry pi
- Make sure the raspberry pi is connected to the internet, then run the following commands to update and upgrade the firmware of the raspberry pi:
- Go to the settings of the raspberry and enable SSH, VNC, and the camera module. Type the following command:
- Afterwards, the software that would be used for the streaming over the wireless network is installed. This software is called mjpg-streamer. The following steps are taken to install and setup mjpg-streamer on the raspberry pi
- Install the dependencies that the software requires by running the following commands:
- Add a dynamic link between the videodev.h and videodev2.h. This is necessary because of the update which has been done to the software:
- Download the mjpg-streamer software:
- Build mjpg-streamer from source:
- The mjpg-streamer has been successfully installed
- Create a file to contain the command for executing the mjpg-streamer. This file is created and edited using the nano text editor:
The file should contain the following:
- Save the file and leave the nano editor
- Make the sreamer.sh file executable
- To run the sreamer.sh file, type the following command:
The streamer software is now running and can be accessed on port 8081.
To access the video stream, the device which is access the video stream has be connected to the same local area network, then a web browser such as Google Chrome or Mozilla Firefox, the IP address of the raspberry pi is type followed by “:8080” i.e <ip_address_of_raspberry_pi:8080>. For example, if the IP address of the raspberry pi on the local area network is 10.0.0.15, the URL to be type is 10.0.0.15:8081.
At this point, the video stream can only be accessed over the same local area network. To make the stream accessible over the internet, a few options are possible. One of them is port forwarding. Port forwarding is not a reliable option as the IP address assigned by the ISP (Internet Service Provider) to the raspberry pi changes dynamically, and to request for a static IP address might not be possible for some ISPs. For the ISPs that offer static IP address to users, it is usually expensive. Therefore, there is the need to employ another approach which would be very cost effective.
The approach employed in this project is tunneling. The major advantage of using tunneling is that it does not need port forwarding to be done on the router and the service is usually very inexpensive or in some cases, free of charge. The major disadvantage is that, since it is streaming video over the internet, the baud rate of both the raspberry pi (the host device that is doing the streaming) and the device that is viewing the video stream has got to be very high else there would be a very noticeable delay between the real-time video and what is being streamed.
In order to achieve streaming over the internet, a service called “weaved” is setup to run on the raspberry pi. This creates the tunneling process in the raspberry pi and opens up a port, which in the case of this project would be port 8081, which can be accessed over the internet. To get this service running on the raspberry pi, the following steps are carried out:* Install the service:
- Signup for a free account on the weaved.com site. Take note of the username and password of the account
- Run the weavedinstaller and configure the settings:
- Exit the installer. The weaved service has been successfully installed on the raspberry pi.
- Start the service on the raspberry pi:
The weaved service is successfully running on the raspberry pi. Once the streamer.sh file is then executed to start the video stream on port 8081 and with the weaved service running on the raspberry pi, the video stream can now be viewed over the internet using the URL that is provided on the weaved account that was created.
Once the mjpg-streamer and the weaved software programs are installed on the pi, to run the programs, the streamer.sh file is executed and the weaved service is started on the raspberry, then the weaved account that was created is logged into and the device is activated.
The flowchart below shows a summary of the process of running the video stream after the weaved service has been installed on the raspberry and the mjpg-streamer software is installed: