Using NGINX Open Source for Video Streaming and Storage

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
everybody James Jones here technical solutions architect for nginx and in this video we're going to show you how to set up your own a little live streaming setup with nginx and it's gonna look this kind of the configuration that we're gonna be going for it's gonna have I'm gonna be we're gonna have ffmpeg as our streaming coder and I'm just going to be streaming a video using ffmpeg using the RTMP protocol to the nginx server that's gonna act as a RTP rtmp ingest and we'll be able to also play back from the same server using our team P HLS and we're also going to add we're now at a third one then we're gonna add - I'm just to show that working and then I'm going to use VLC to do the stream playback so the way you get started with this is that you log in to your Linux machine and and this one I am actually using in bun - I'm using a bun - Bionic 18:04 and there's some things you're going to need ahead of time to do this compile you gonna need your compiler you're gonna need make Auto Kampf and a color other developer tool other developer tools which comes in this bill the Central's package and then you also need PCR III Lib SSL and Zeeland Linsey live use compression on HTTP so I'm gonna go ahead I'm gonna add these packages all right looks like they were already installed on this machine great now the next thing you want to do I'm I'm just gonna make a little temporary build directory for myself just going to call it nginx and change to that directory and then there's two repositories that you're gonna want to clone boom you're gonna want to get the RTP module that's this one here and all the links are going to be posted either in the description below or on the blog post so this is part of and then I'm gonna use the master branch from the nginx repository or you can actually go to github there go to the releases and pull one of the tarballs but I'm just gonna use a kid here so let's clone the rtmp module and now we're going to clone nginx ring going to enginex directory here and then work around and configure and compile using the our team you module now one thing to note when you're building directly from a git repository you will need to run the configure command from within the auto directory like you see here and if it's a regular released of all the configure command will be right in the root under the auto all right so we're all configured here go ahead and make and this will take a few moments to compile um the cool let's but this is one of the cool things about nginx is that I'm compiling this live now it's so tiny and lightweight but it can do so much so it's it's this is what I think one of the things I find amazing about nginx and it shouldn't be too much longer here and there we go and then we're gonna do a sudo make install and it when you build from source and you don't define the prefix and you can in your configure command it will actually install it and use their local nginx now before we continue I want to go over go over the nginx configuration that I'm gonna be installing here and kind of walk you through it these are kind of the typical defaults that you see and any engine X config um but what we really want to pay attention to is this RP rtmp context and this HTTP X and with the HTTP or with the rtmp context here where you do going to be putting a server context and we're going to listen on 19:35 that's the default tcp port for rtmp and then we're going to add a application context an application context is it's like different rtmp and points and this one I just happened to name live and what you want to do is you want to have live on interleaf really isn't important but it's a optimization for combining and letting it know that you're going to be combining the video and audio chunks within the same Artyom Artyom P packet and we want to turn HLS on because we want to have HLS playback from old devices like iOS that we wanted to find a path or where the fragments are gonna go and then we want to set how long the fragments are gonna be and we want to do very similar thing for - so - on the - path and the - fragments pretty identical now another cool feature that you can do if you don't want to if you don't have like a broadcast machine but you already have a stream that you that's already going someplace and you want to pull and you're doing this to kind of build in some more redundancy adding a more capability or more capacity to be able to view that stream you could actually just do a pull from the RT rtmp location for it and but one of the important things you really need to give it that name tag is without that name tag and will not be able to auto-generate the metadata and the and the files that are needed for generating the HL s and - files and I'll show you I'll show you that of how that comes into play later on now let's go over the HTV HTTP contacts configuration we just have our default mime type and we're just setting up a server context we're gonna have it listen on port 80 we're setting the root location just root TMP because that's where we're putting them - in HLS and then we're just defining some mime types here or you know for the HLS metadata for the HLS fragment web pages obviously and for the - metadata so pretty straightforward not too terribly too difficult and there's other things you can do to optimize but this is kind of like minimal Viable Product just to get this working now to show you what you can do and I already happen to have the config on this machine I just need a copy in place whoops what do they do there that was that was silly and B copy want a copy there alright so we got the configuration there so what we want to do is we want to vary we want to validate we want to validate the configuration I mean you can do that with giving the nginx command a minus T and the configuration is good and tests are successful so now we're just going to run the nginx command without any options and away we go so now we're going to go ahead and we're going to start our stream I already have a file item in a stream it's a big buck bunny video the open source a little animation thing that blender did so we're gonna go ahead and get that streaming and we're going to bring up three instances of VLC so I can show you the three different playback methods all right great so let's go ahead and we'll open up the rtmp one first now one two point one thing to point out but I wanted to point out before before you before I knew that got is if you look here let me see if I can make it a little bit bigger like this a little bit bigger right here the our our team P address which I'm streaming to which is that live which is the application name and then the name I want to give the stream and this is really important because you need a name that will get prefixed to all the automatically generated files for the HLS and - streams and I can show you now cuz that should be up and running if we do a let's switch to root real quick now if we look at the - directory you can see that name is what's prepended to all these files for the - stream and you'll see the same thing or the HLS which is pretty important that's how you you can actually have more than one RTP m RT cmp stream being ingested as long as you have a different name on it you can you can have multiple streams coming in and being re encoded or not ring code it but split up for HLS and - which is kind of cool so now let's go ahead and open up our TMP way [Music] and then put out one of these other ones this one we're going to do hls stream there's it it this way and you can see that I'm HL s BB B dot H is if we're going to load up them at a data file make sure we put the HTTP in front as if we have to go to the web server start pulling those files and next we will pull up the - one [Music] d that one is in the cache directory here shortly and there you go though you have your own live streaming setup and three different ways to watch with this example I hope that was helpful you guys have any questions let us know we'll be more than happy to help and thanks again for watching
Info
Channel: NGINX, Inc
Views: 83,167
Rating: undefined out of 5
Keywords: NGINX, NGINX Plus, NGINX Controller, NGINX Load Balancer, Load Balancer, NGINX API Management, NGINX Unit, NGINX Open Source, NGINX OSS, NGINX Systems Engineer, Video Streaming, Storage, Configure HLS, Configure DASH
Id: Js1OlvRNsdI
Channel Id: undefined
Length: 14min 10sec (850 seconds)
Published: Mon Apr 13 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.