Serving a video library is a great use for a home server. Explore the Plex software for sharing movies and home videos.
- [Scott] If you have a lot of video files, for example, home movies or old films that are in the public domain, it can be convenient to set up your home server as a video streaming server, so you can watch them on different devices. With a file-sharing server set up, you could pretty easily load a file up in a video player on your computer, but if you want to watch your media on a set-top box or a mobile device, that's not as elegant of a solution. Let's take a look at Plex, a video streaming service that has apps for most major computer platforms, set-top boxes and mobile devices.
Plex is very good for organizing your media into libraries and keeping track of various metadata about it. As we'll see with some public domain videos available from the Blender Foundation, Plex can go out and get art, cast information and more from databases online. You do need to sign up for a free account to use the Plex software so be aware of that before we get too far into the process. I've already done a little bit of that cooking show magic, where stuff is already prepared. I've downloaded a handful of these Blender videos and there's a listing of them in the exercise files, with URLs so that you can grab them as well.
I'd recommend finding the version of the media that's best suited for your system and viewing experience, and using Wget to download it to your server. We'll go through that for one video here, though. After we do, you may want to pause the course and download some others, or, if you happen to have your own video media you can follow along with that instead. Here on the page for one of the videos, I'll make sure I'm on the download page, and I'll scroll down until I see the links where I can download it, there's a bunch of different options here, and then I'll choose the 1080p mov version, and I'll right click on this link here, and copy it.
Then I'll go back to the terminal, and type wget, and I'll paste my link. Depending on the speed of your internet connection this could take a few moments. And now that that's downloaded, let's take a look at what we've got. Four movies. Let's create a folder on the storage drive to store these. I'll write mkdir /mnt/storage, and we'll call the folder media, and then I'll move all of these files over there. I'll write mv *.m*, we've got a couple different types here, to /mnt/storage/media.
Let's double check that they got moved. ls /mnt/storage/media There they are. I'll clear the screen. Now we need to install Plex. There's two ways to do this. You can download the installer from Plex.tv, and install it with dpkg -i, or you can follow the directions on one of the support articles to add the Plex repository to your system. I prefer this method, because it makes staying up-to-date much easier than manually downloading and installing the updated version by hand.
I'll visit the support site at support.plex.tv, and I'll search for repo. In this article here, Enable repository updating for supported Linux server distributions, is exactly what I want. Down here, under Ubuntu, are two lines that we'll copy and paste. Normally, you want to be very cautious about just copying and pasting terminal commands from the web, especially if they're using Curl or Wget, and sending that output straight to the shell.
So, before we copy and paste, let's take a look at what these commands will do. This first line is actually two commands all in one. What this will do is echo, or print out the text, deb, and the repository URL and public main. In fact, we can just take that part and run it by itself if we wanted to. The shell would just return this text. But when we follow it with the pipe character, instead of printing that text to the command line, it'll send the text to the next command, sudo tee.
Tee takes input and writes it out to a file. And sudo is required here, because the file we're creating is in a system folder. We could just as easily use a text editor to create this file and type in this text here. But this is a handy one-liner to do the same thing. Now, having examined this, I'll copy it, and I'll paste it over in the shell. There's that, and then I can use cat to look at that file, etc/apt/sources.list.d/plexmediaserver.list to see exactly what it did.
What this accomplishes is to add the Plex repository to a list of places the package manager will look when it's searching for software and updates. In order to use that repository, though, we need a key. And that's what the second line of the commands in this article accomplishes. We're using Curl to download a public key. Again, we can copy and paste just this part to double-check that we're not getting something malicious. And here I can see, in fact, it's a public key. And here in this combined command, that key is piped into the apt-key command, which adds the key to the package manager's list.
Again, this is something we could do manually, in two steps, if we wanted to. But I'll copy these and paste them and now that's done. With the key and the repository added, we need to tell the package manager to update the list of software that it has. We'll do that with sudo apt update I can see here that the package manager is going out to the Plex repositories in addition to the regular Ubuntu ones. When it's done, we can use the apt install command to install the Plex media server.
It's sudo apt install plexmediaserver, all one word. Here I'm being prompted by the package manager to update a file that was created either by me or by a script. It conflicts with a file that's provided by the package maintainer, so I'm being given the choice if I want to install the package maintainer's version, keep the currently installed version that I have, examine the differences, or start a shell to examine the situation.
I'm going to accept the default to keep my currently installed version. When it's installed, I'll clear the screen. The system will automatically start up the media server, which I can see with systemctl status plexmediaserver Now that that's running, we can use the web interface to configure the server. The web interface runs on port 32400, so let's enable that through the firewall with sudo ufw allow 32400/tcp and then let's go to a browser and take a look at the webpage.
I'll write, 192.168.0.2:32400/web To sign up for the free account, click on Sign Up over here. You can choose to sign up for a Plex Pass if you want. Sign up with your information, and click through the process. You can choose to sign up for Plex Pass if you want the services offered by that, but if not, just close the dialog. When you've done that, log in with your new information.
You can give your server a name, and choose whether you want Plex to try and make your media available outside your network. We'll go over that more later on. I'll click Next, and we'll add a library. This is going to be a movies library. If you have a lot of media, or different kinds of media, you can create different folders and different libraries to keep them organized. Plex can serve music files and photos in addition to video.
I'll name this library Movies, and I'll click Next. Then, I'll browse for the media folder that we created earlier, that's off of the root, in the mnt folder, storage, media. And I'll click Add, then I'll click Add Library. Already, down here, you can see it's looking for information about the videos that it's finding in my media folder. On the next screen, it offers some information about Plex apps. You can get an app for iOS, Android, Apple TV, Roku, Xbox, Fire TV, and even for your desktop or laptop computer.
If you do, just sign in, and you'll see your server on your network. For now, I'll click Done. Here in the web interface, I see my media library. If I mouse over the thumbnail, I can see some options. The pencil lets you edit information if the automatic matching didn't work quite right, or if you have something that won't be in an online database, like a home video of your first time riding a bicycle. You can add all of that information here. You can set tags, change the poster art, and so on.
I'll cancel that for now, and if I click through to the media screen, I can see all of the metadata that Plex was able to download from the internet, and I can even watch right here in my browser. I'll close out of this for now, and I'll go back to my movies library. There's lots of options to explore, but I'll point you to just a few right now. Up here at the top of the interface is the status icon, which shows recent events on the server, and next to it is Settings, where you can make some changes to how the system works.
Under Server up here, and Library, there are options for how often to update the library. If you have a lot of items, it can take a while to update the library. Updating the library checks to make sure that everything in your Library folder on the disk is reflected in the media library in Plex. If you just leave this automatic option selected, Plex should keep an eye on the Media folder, and add new things to the library shortly after they're added to the folder. It's not instant, though.
Down here under Transcoder are some options you may need to play around with for different types of media. Most of the time, on your local network, Plex will stream the file directly to your device, and it doesn't take too many resources. But if for some reason it does need to transcode or live-convert the file, that can be resource intensive. Plex's website has some recommendations about what class of processor you'll need to do various kinds of transcoding. Suffice to say, if you're using older or less powerful hardware, don't be surprised if it can't keep up with a 1080p stream in an obscure format.
Another neat feature is that the Plex server can act as a DLNA server. So many so-called Smart TVs will be able to discover the server and stream video, without needing an app at all. At home, I go between using Plex on my Apple TV and my Xbox, and it makes streaming your video on your network very easy.
- Setting up a home server
- Creating an installer from Windows, macOS, or Linux
- Installing Ubuntu Server
- Configuring the network for a server
- Adding storage with a local disk
- Sharing files on the network
- Serving up video over the network with Plex
- Blocking domains on your network
- Backing up your server and files
- Using Dynamic DNS for external access
- Sharing and syncing files with Nextcloud