Live streaming video cameras can be used for security or personal purposes. A variety of webcams, camcorders, DSLRs and mirrorless cameras for streaming live video are available in the market. You want to own one too but can’t afford it! Don’t worry, we will help you build one yourself at less than Rs. 2000.
Today, in this DIY project, we are going to make a live streaming camera that can be accessed over Wi-Fi. The best part of this project is that you can view the video live streaming on multiple devices like computer, tablet and phones. You can also move its camera lens wirelessly for wide-angel views. Another interesting thing is that you can set this camera in a motion detection mode to enable it to take picture or record video when motion is detected. However, you may experience video lag depending on the Wi-Fi network.
We can make this project by applying two methods, which will be explained below.
Setting Raspberry Pi for camera
First, you have to set up the Raspberry Pi for camera interface. Open the terminal and run this command “sudo raspi-config”. Then you will get a blue colour window with several options. Select the “Interfacing” option and enable the camera interface. (Refer Fig 2,3,4).
Now, your Raspberry Pi is ready for camera interface, meaning you can start streaming camera video over Wi-Fi. You can archive this using the following two methods.
Streaming Camera Video using VLC player.
In the first method, we are going to stream the camera video using VLC player. To do this, first open the terminal window and type the following command to install VLC on your Raspberry Pi.
“Sudo apt-get install vlc”
After the successful installation, you can stream your camera video using the following command
“raspivid -o – -t 0 -n | cvlc -vvv stream:///dev/stdin –sout ‘#rtp{sdp=rtsp://:8554/}’ :demux=h264”
To obtain the output of the video streamed by the camera, connect your PC or phone to the same Wi-Fi network on which Raspberry Pi is connected. Next open the VCL player, then go on stream menu and paste the url.
rtsp://ip address of your pi:8554/
Now, open the text editor and put the following code in it
And save it as cam.py and whenever you want to live stream a video, run this program.
Streaming Video Using Motion
Open the terminal and run the following command to install motion “sudo apt-get install motion”
Then setup setting to run the camera server continuously on background
“sudo nano /etc/default/motion”
start_motion_daemon=yes
Then make some changes in motion config as described below (Refer Fig 5).
Run this command
“sudo nano /etc/motion/motion.conf”
Do these changes according to your need
Stream_port=8081
Stream quality 50 # set the quality according to your need
# Allow motion to run the daemon we’ve set earlier
daemon on
# set the framerate of the stream (100 for higher quality)
framerate 100
# set the width and height of your video
width 640
height 480
# control de port 8080 by default
webcontrol_port 8080
# careful! don’t set the stream_port just like the webcontrol port
When you done with the above setting, save and exit the config file using key “CTRL + X”. Then hit the Y key and then press enter.
To start camera video streaming, open the terminal and run this command
“sudo service motion start”
“Sudo motion”
Now, connect your PC and Raspberry Pi on the same network. After that open any web browser and type the following url
https:// ip address of your raspberry pi:8081
Now you can get the camera video streaming on your web browser.
Cam video output either over HDMI or RCA composite
If you want to get video output like other surveillance cameras on RCA composite or on HDMI without any video lag, then create the following python code and run that code to get Raspberry Pi camera video on your TV screen.
Giving movement to camera
Create a python program as in code snippet below and run the code for movement of servo motor.
As you have completed the setting and software part, it’s time to put together the whole stuff in an enclosure.
First connect the servo motor to Raspberry Pi pins as illustrated below
Motor PWM signal pin (Orange colour wire) to Raspberry Pi GPIO
Servo motor VCC to 5V power supply
GND to Power supply GND
Raspberry Pi GND to Servo Motor GND
Now, put the Raspberry Pi in camera case and fix everything according to the pics shown below –
Download source code: click here
How do I make it stream to Youtube?
You can try by Youtube livfe
this project comes under which domain?
This project comes under Electronics Projects.
What is the cost of all of this?
none of it worked I found I already had VLC on my Raspberry Pi desktop but none of the commands would let VLC recognize the cam. Waste of time
It will work , Its tested two three times. Check camera interface is turned on and then uninstall VLC and re-install VLC using steps as described in the article.
Now that Pi Bullseye has come and raspivid is replaced with libcamera-vid, can you please update the article accodingly?
I want to connect to my Pi from a browser on the LAN.