Beginner Tutorial: How to Stream Video from Raspberry Pi Camera to Computer using Python (P2)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] what is going on everyone welcome back to the channel and today's video we will be doing a part two of the video series where I demonstrated how to stream video from your Raspberry Pi camera to your local computer all over the local network using flask which was really easy to set up and I have the script in front of me here as you could see in this video instead we'll be doing an ADD on on top of that where I will show you how to stream video not only on your local network but any Wi-Fi enable device will now be able to view the stream at the end of this video so I'll be walking you through step by step of how to get that set up on your raspar Pi all by using a simple tool that we will download and configure on our Raspberry Pi and by the end of it you will be able to go to a coffee shop somewhere far from your Raspberry Pi camera that's not the same local network and go to a URL where you will be able to view the video stream in real time so be walking through that step by step before we get into it be sure to watch part one if you haven't already because that goes through the code we have set up right here which we'll be using as the base for this video and even better be sure to like comment subscribe to the channel and even better than that consider donating to the channel in the link down below and enough being said let's get started okay so first things first you can see I have the code we set up in the first video One Thing alarming you might notice is if you did watch the first video I'm actually using a different IDE do not be alarmed this is just personal preference and I'm just just using visual studio code on my local computer to write code via the SSH protocol onto my Raspberry Pi you can use the same Technique we use in the first video just go to th on your Raspberry Pi and code on there that is fine I'm just doing this because I prefer it and I actually don't have a mouse right now to code on my Raspberry Pi in the first place so if you guys are interested in that I will link that video series of how to get Visual Studio code set up for your Raspberry Pi to code on it other than that we have the same exact code as we went over in part one which allows us to stream video over a network using a flask app so what we want to do on top of this is we want to configure this to allow us to stream from any network and in order to do that we're actually going to use a tool called enro so enro is a free tool that's easy to set up and downloadable on your Raspberry Pi and it will create something called a local host tunnel which will tunnel the requests to a web URL to the Local Host on your Rasberry Pi so when people go to the enro URL they will actually be tunneled to the local host flask app running on your Raspberry Pi and best of all it's incredibly easy to set up and free to get started with enrock so we'll be using that tool so the first thing we have to do to get started with enro is we actually have to download it on our Raspberry Pi so in order to do that we just want to go to enr.com I already signed in and created an account it is free they do not ask for any credit card information and once again we will discuss the pros and cons of using enro to do such a thing so we'll get into that in a bit but once you are on enro be sure to go to the dashboard and you can see they have many agents where you can download enro on we just want to go to Raspberry Pi and we just want to scroll down and go to apt I use the APT installer on my Raspberry Pi and you just want to copy this first link to to download it I already have it downloaded but I'll just show you so I am in a terminal so if you are signed into rasby Pi you could just open a terminal app and do the same thing and you just want to go ahead and copy that link and click enter so I already did that I'm not going to click it again and so that's the first thing you have to copy in and click enter and then once you have that you just want to do the next one so you just want to take this next command that they have here for us and you just want to paste in the terminal and click enter it has this this key here so keep that secrets I'll probably change mine after this video I don't think it's that big of a deal however just keep that off token as secret as possible so those are the two things you only need to install enro on your Rasberry Pi so once you have that and there's no errors you should have the enro program downloaded on your wber Pi which will allow you to create this Local Host tunnel and that will make much more sense in a second here where we will be able to hit that URL from any device that has a Wi-Fi connection and be able to view the flask app on our Raspberry Pi because it's running this enrock program in the background so that's what we're going to do here so in order to do that next once we have enrock we actually just want to run enro so in order to run enro let's actually just type in enro HTTP HTTP Local Host 5000 and one thing I'm going to do here is I'm actually going to delete this video feed so before what happened was in order to view the video feed you have to go to the video feed extension in the flask app now we're just going to make the base base URL where the video stream is so let's go ahead and save that and let's go ahead and now run this engro command so once we click enter and everything works we should have a generated UR L from enro that will that this is a public facing URL so anyone on the internet that is is outside your local network or is even on your local network can actually click this URL and be funneled to this Local Host 5000 on your Raspberry Pi so in the first video what happened was if you actually tried to view Local Host 5000 from an external network it just wouldn't take you anywhere so what we do on top of that is we add this anrock layer which will create the funnel request to your local host on your rest Pi which will allow you to view the video stream so this is a randomly generated URL so every time we actually run engra we're going to get a new URL so this is one of the cons of using the free version of enrock is that this is a dynamic URL so if you want to make this a serious application and Eng Ro you probably want to do the paid version so you can get a nice stable URL that all your viewers can uh view whenever the the stream is accessible however just for video demonstration purposes we'll just use this randomly generated URL and the enro free version and so once we have this randomly generated URL the next thing we want to do is we just want to run the flask app as we did in the first video so I am just going to go to a new terminal on my Raspberry Pi here and the only reason I'm doing this is because I'm just running the program through the CLI if you are using th on your Raspberry Pi you could just go ahead and click the play button and it'll be the same thing so we just want to do python actually I want to go to the directory where that is so it's in my desk top and we just want to start the video stream so python stream. the only thing we Chang in this code from the first video is we just made the base URL the the URL where the video feed is is being sent to as opposed to having that extension and so now we are running the flask app and we also have the Local Host tunnel from enro running on top of that so now we should have everything set up to view this URL and see the video stream from any device okay so just to prove to you that this URL is working we're just going to go ahead and copy this URL on our local computer's browser so we just go ahead and paste there I already visited before recording just to make sure that it's working and it is and the first time you go to these URLs it will ask you to visit the site so you can just go ahead and click that button you can see right away we are viewing the video stream one thing you'll notice is if you're looking at the video stream you'll notice that there is some lag and one way you can overcome this is you can actually pay for the paid verion of enro and you can get some more bandwidth right now it's not entirely responsive so there is a few seconds of lag so nonetheless I still think this could be used for a good home security camera or monitoring system despite the few seconds of lag and another way you can overcome this is of course improving your internet connection the the bandwidth of your Internet to get a faster stream so that's one way however that that is a con of engra despite the easy setup there are some issues with latency which is okay so you can see right I just put the camera down so it is now it's stabilized it's fine so it looks like to be working so one thing I want to do is actually I want to view this URL not only on my local network but on my phone which is not connected to my local network so I'm just going to go ahead and close this and another con is the reason I close that is because we can't view the URL for my phone and the laptop at the same time because on the free version of enra it will not allow you to do that so you actually have to pay for the paid version of engro to view multiple streams so that is another con unfortunately of using the the the free version of enrock so I'm just going to go ahead and open the stream on my phone just to show you guys I am not crazy and it does work on an external network let's go ahead you could see right away it's asking me to visit the site on my phone which is fine and you can see that I am vieing the stream I'm not moving the camera I can go ahead and move it a bit there it will take a few seconds to respond of course the internet on my phone is not as fast as the internet on my laptop because I'm using not my home Wi-Fi on my phone I'm just using my internet provider or my service provider that is AT&T so we could see that it is responsive so still pretty cool and I think you could do a lot of interesting things as we mentioned in terms of of home monitoring and security systems just based on this engro configuration so that's it for today's video guys I hope you enjoyed the tutorial overall we went over a very simple methodology to make a publicly facing video stream from our Raspberry Pi using the camera camera and flask all with some simple code and a really simple tool that is enro that allows us to be able to do this we discussed the pros and cons it is very simple it's free to get started however we do have some issues in terms of latency and being able to view it from multiple devices and there are some ways to overcome this as we discussed in the video If there is more interest to see more sophisticated ways to create streams uh you can do some more intricate things with AWS and other Cloud providing services to make this stream more accessible and more robust and lower latency so if you guys are interested in that let me know in the comment section down below if you enjoyed this video overall and the Channel please be sure to like comment subscribe if you haven't and even better consider donating once again because that would mean a lot your support means everything to me stay tuned guys thanks for watching and take it [Music] easy
Info
Channel: Shilleh
Views: 2,576
Rating: undefined out of 5
Keywords: Raspberry Pi Camera, Flask, Python Flask, Video Streaming, Backend Development, Raspberry Pi Camera Flask, Picamera tutorial, pip, python3, DIY Raspberry Pi, Raspberry Pi Beginner Tutorial, Raspberry Pi 4b, ngrok, local host tunnel, Camera
Id: p4L3g9Grl3k
Channel Id: undefined
Length: 10min 28sec (628 seconds)
Published: Sat Mar 16 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.