How To Set Up A Live Video Stream Over LAN With Raspberry Pi & Linux

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right [Music] hey welcome back to phaser Tech today I'll be showing how to set up a live video stream using your Raspberry Pi's camera that can be viewed from any computer connected to your home network this guide is a continuation of my previous video where I showed how to install the diet Pi operating system so if you haven't set up your Raspberry Pi yet then you should definitely see that one first the packages I'll be installing today will actually work on any Debian or Ubuntu based System including desktops and laptops with webcams but a few of the steps and configurations will be slightly different so I'll try to point out the differences as I go in case you wanted to try it with something else other than a Raspberry Pi also if you're already running with the regular raspberry pios then you can also follow along with most of this guide too but again there will be a few minor differences so if you want to follow every step of this guide exactly then I encourage you to check out my previous video and install diet pie and one last thing before I begin I'll be releasing more tutorials in the near future showing how to create a custom Python program for a smart camera that will automatically record only when motion is detected so if you're interested in learning Python Programming then be sure to subscribe to the channel so you can stay up to date with this series of videos alright let's get started first make sure your pie is connected to the network through Wi-Fi or ethernet you'll also need a camera there are several different versions of the Raspberry Pi camera but if you're on a budget then the first version is only 10 bucks now and it still provides good quality with up to 1080p 30fps video which is more than enough for a security camera I'll be using this one today also USB cameras will work too but the CPU usage will be higher and can slow down the older Pi models so I recommend a Raspberry Pi camera let's begin by logging into the pi with the root user now before we install packages let's update the repositories by typing sudo apt update after they update type sudo apt install v4l-utils and confirm the installation this package allows for extra options and customizations with the camera it shouldn't take long to install next let's install ffmpeg which provides the media codex so type sudo apt install ffmpeg this package requires a lot of dependencies so it'll take a while to finish installing once it's done we're ready to install rtsp simple server which is a network server that uses the rtsp protocol there are other protocols that are commonly used as well but I found that rtsp offers the best performance and latency we'll need to download this software directly from GitHub if you're using a desktop or laptop then you'll want to copy this file name here Linux AMD 64. copy the file name so you can paste it in the following command in a minute if you're using the original Raspberry Pi or the Raspberry Pi zero then copy this file name with the rmv6 in the name if you're using an 8 gigabyte Raspberry Pi 4 with an rmv8 image installed then you'll need this arm 64 V8 file but for the majority of Raspberry Pi users you'll want the armv7 file this is what I'll be using so I'll copy this file name before downloading it first make sure you're in the home directory you should already be in the home directory but in case you're not just type CD tilde to get there now the following command is a long one so I left it in the video description to make it easier for you to copy and paste just make sure the file name in the command matches the file name you copied a minute ago you can see I'm using the rmv7 version this command will download the compressed file and then extract its contents all right so we've downloaded all the software we need to get the stream working all we need to do now is run it but instead of manually running these commands every time I turn on the pi I'm going to set an automated bash script that will run each and every time the pi is powered on the script runs quietly in the background and doesn't require any input from the user to do this let's go into the diet pies configuration by typing sudo diet Pi Dash config keep in mind this process and the file you need to edit will be different on other operating systems but you should be able to use the same bash script I'm about to use Now navigate down to auto start options next go to the other section and then select custom script foreground with auto login and enter use the arrow keys to navigate the cursor above the Exit 0 Line This is where we're going to paste several commands to start the video server I'll also leave this in the video description so you can easily copy and paste it the last line is very long and it runs off the screen here so I'll use the arrow keys to scoot over to the beginning let's go over each of these commands and what they do the first line starts the rtsp server that will communicate with the local network the next line sets the Raspberry Pi camera's bitrate if you're not using the raspberry pi camera it's important to remove this line completely since it probably won't work with other cameras I have mine set for 15 megabits which I found to be the optimal bit rate for the Pi's camera at this resolution and frame rate you can set this value higher but I didn't notice a quality difference at this resolution so I think it's better to save the bandwidth lowering the bit rate might be a good idea in certain situations but I'll come back to this in a minute the next line starts the camera and this is where you can change the video settings if you're not using the raspberry pi camera and using let's say a USB camera then you might need to change the dash input format and the dash F input parameters since certain cameras use different compression methods I found that my logitech's USB webcam works with these settings but my laptop's built-in webcam required a different input format to work if you have multiple cameras connected then you can specify which one to use with the dash I tag if you only have one connected then it will always be video Zero if you connect a second webcam then that will be assigned as video one and so on you can also select the video resolution and frame rate here but this will depend on what your camera is capable of you can see here the different video modes that the Raspberry Pi camera version 1 is capable of doing take note the different resolutions also give different fields of view so if you want the widest field of view then you'll actually want to go with a lower resolution than 1080p also notice this list that shows which frame rates are supported for each resolution keep in mind the original Raspberry Pi and the Raspberry Pi zero might struggle with 1080p 30fps video These models only have a single core CPU while all the other Pi models have a quad core which gives a massive difference in performance so if yours has a single core CPU you'll probably need to lower the bit rate and the resolution to 720p if you want smooth frame rates especially if more than one computer will be viewing the stream also if you have network problems such as a bad Wi-Fi connection then lowering the bit rate can help sometimes too now the setting you need to take note of is the address which your stream will be broadcasted too right now it's said to be called My Stream but you can name this whatever you want I'm going to change it and name the stream feeder but make sure to leave the rest of the address as it is it'll be broadcasted to the Pi's IP address on Port 8554 now let's save the file press Ctrl X and you'll be prompted if you want to save type Y and enter to confirm and enter again to confirm the file name select root and press enter now navigate out of the menu by going to exit and exit again and then select ok now let's reboot the system if everything went smoothly then you won't need to log into the pi every time it turns on it will automatically start broadcasting the stream now to view it I recommend using the VLC media player which is available for Windows Mac Linux and other platforms too including Android open VLC and click media in the top left corner then go to open network stream enter the streams address here which will be rtsp colon slash slash followed by your Pi's IP address then colon 8554 slash and the name of your stream which in my case I called feeder now all we have to do is push play and wait a few seconds and you should now see your live video stream playing it might hiccup for a second at the beginning but once it gets going it should be a Flawless stream with minimal latency as long as you have a good network connection [Music] well hopefully you found you found guide easy to follow if you enjoyed it then please like And subscribe to help my channel grow like I already mentioned I plan to return to this project and do a series of videos teaching Python Programming but it might be several weeks before I return to it because I have a few other Tech related videos planned first so please stay tuned also feel free to leave a comment if you have any questions or a suggestion for a project as always thanks for watching and I'll see you next time [Music] [Applause] foreign
Info
Channel: Phazer Tech
Views: 16,382
Rating: undefined out of 5
Keywords:
Id: kfHVxvMZMnw
Channel Id: undefined
Length: 11min 13sec (673 seconds)
Published: Thu Oct 06 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.