LJ Archive

The Open-Source Classroom

Plex, All Grown Up

Shawn Powers

Issue #279, July 2017

Plex used to be one more option for media consumption. Now it's starting to become the option.

If you aren't using Plex in your home network, this guide might be all the reason you need to start doing so today. I've been using Plex for years, and unlike all the other programs and hardware options I've tried for media streaming in the past, Plex continues to get better and better instead of just dying out. I have boxes full of things like Popcorn Hour media streamers, Boxee Boxes, Cubox Kodi machines and countless other devices that were the best of breed at one point or another. But Plex has never let me down, and now it has so many features and hardware integrations, I don't see it going away any time soon. So in this article, I describe setting up a Plex infrastructure. There's no single way to do it, so let's start at the beginning: the server.

Server Options

Plex will run on a wide variety of platforms. Most NAS devices will run the plexmediaserver application, and it will run on Windows, Linux or OS X. Although running on a NAS seems like the logical place to have it run, the unfortunate downside is that NAS devices aren't powerful enough to transcode media for streaming. Basically, unless the file is in the exact format needed for your playback device (web, Android, Roku and so on), the server will transcode media on the fly so you can watch it. In order to transcode, you'll want as much CPU as you can afford. This is especially true if you'll have more than one stream running at a time.

I have an older i7 Intel box running eight cores at 3GHZ. It can transcode 3–4 1080p videos in real time without too much trouble. I'm running Ubuntu Server without a monitor, but the program will happily run in the background on your powerful workstation too. It doesn't have to have a GUI open and simply will run as a service in the background.

If you pay for the Plex Pass subscription, you also have the option to run plexmediaserver in the cloud at no additional charge. I'm a lifetime subscriber to Plex Pass, so if I wanted to offload all the transcoding to the Plex servers, I could do that. The only problem with running Plex in the cloud is you have to store all your media in Dropbox, Google Drive or OneDrive (Figure 1). Since that storage isn't free, you still end up paying. The upside is transcoding will work without the need to buy a powerful server. It's certainly an easy way to try Plex.

Figure 1. Cloud storage is great, but it can become expensive when it's counted in terabytes.

Installing and Updating

Since the plexmediaserver is proprietary, you'll have to download the binary from the website: https://www.plex.tv/downloads. Downloads are available for a wide variety of platforms, as you can see in Figure 2. When you log in to the web interface to watch videos or configure the server, it will tell you whether the software needs to be updated. Thankfully, on a Linux server, there's an even easier way to keep things up to date.

Figure 2. Plex is available for a wide variety of platforms.

Over on GitHub, user mrworf has created an automated bash script that will download and install the newest version of plexmediaserver. It even supports logging in with a Plex Pass account, so you can get the latest features without logging in to the website to download the installer. Check out https://github.com/mrworf/plexupdate for a one-liner install that will configure your server to download and install new server software as it's released automatically. With the need for authenticated downloads for Plex Pass users, it used to be difficult to automate the process. Thanks to mrworf, that's no longer a problem!

Once you have the server installed, open a web browser and connect to http://localhost:32400/web to configure. If you're running on a headless server, you should be able to connect from another machine. Just go to http://plex.server.ip:32400/web and configure it remotely. If the server is listening only on localhost, you might have to do something like an SSH tunnel for the initial configuration. On your GUI machine, do something like:

ssh -L 32400:localhost:32400 username@plex.server.ip

Then on your GUI machine, you should be able to connect to http://localhost:32400/web and actually be connected to the remote server. SSH is awesome.

Once the initial setup is complete, your media folders will be added. Plex is fairly flexible with naming formats, but basically, if you want your movies and television shows to be tagged properly with metadata downloaded, you need to name the files appropriately. For example:


Again, Plex is flexible when it comes to section separators and such. For movies, the important thing is to have the title and year, and for television shows, the show name along with season/episode information. Plex will search subfolders, so it's okay to keep your videos organized in folders. For example, I have season folders for my shows.

To add a folder, simply click the + next to the library section on the left. Then you must select the library type (Figure 3). The reason for selecting a type is that movies are scanned from databases that are different from television shows or music databases. Also, Plex supports photos and home movies, which aren't scanned for online metadata at all. Once you add the folders to a particular library, Plex will scan for content. Notice that a “Library” can have multiple folders. This means if you have several locations where you store movies or television shows, you can add them all to the same section in Plex so you don't have “TV Shows 1” and “TV Shows 2”. Plex just combines all the folders in the database and presents the content as one.

Figure 3. It's a little confusing at first, but the library “type” is for better metadata.

More Than Just Local Files

Normally, I rip Blu-ray disks manually and add them to the server, which scans and adds them to the library. Recently, the folks at Plex have added DVR and Live TV support. It's currently in beta and available only for Plex Pass users, but the integration is nice.

The simplest way to implement the DVR system is by installing a supported tuner. Some in-server tuners are supported, but I prefer to use a network tuner like HDHomeRun. Whether you're using OTA broadcasts or cable TV, if your tuner is supported, Plex can find guide data. Figure 4 shows the DVR setup, which is extremely simple.

Figure 4. The HDHomeRun was detected on my network automatically.

Once configured, a new section called “Program Guide” appears in the left column (Figure 5). Rather than showing a traditional programming grid, Plex displays currently playing shows along with what will be starting soon. It's a different television interface from what I'm used to, but with the limited number of channels I receive OTA, it was tolerable. From inside the guide, you either can tune in directly to watch live TV (on supported devices, which at the time of this writing is mainly mobile devices) or schedule a recording.

Figure 5. The program guide takes a little getting used to, but it certainly integrates well.

When a recording is scheduled, you're asked where to store the video. I keep my recordings in a separate location from my ripped videos, because I don't want to confuse recordings with commercial-free DVD rips. Plex downloads metadata for recorded shows and puts them in your library alongside other videos. I actually wish there was a way to tell which videos were recordings and which were ripped, but right now, that doesn't seem to be possible. Nevertheless, being able to watch live TV from anywhere is awesome.

Logs and Data and Stats, Oh My...

One area Plex is lacking is in the log department. That might seem like a strange complaint, because there is an error log if something goes wrong. But since I have a server and share access with a few friends, I really like to know what my server is doing. My wife thinks it's creepy that I have a log of everything everyone watches, but my concern is more with how well my server performs with multiple streams and so forth. Thankfully, there's a third-party open-source project specifically for keeping statistics about the Plex server. It's called PlexPy.

If you head over to https://github.com/JonnyWong16/plexpy, there are some simple instructions for installing PlexPy on your server alongside plexmediaserver itself. Using git, it even has a smooth update feature so you can just click a button in the web interface to upgrade. Installation is simple, and although the directions say you must connect to localhost in order to access the interface, my install was listening on all interfaces by default. I was able to connect to http://plex.server.ip:8181/.

That will take you to the initial setup, which will connect PlexPy to your server. At first, the data is underwhelming, because PlexPy records statistics itself as opposed to reading information from a log file. So when you initially install it, there's no data to display. After a few days (or hours, if you have a house full of teenagers), the statistics begin showing more information.

Figure 6 shows my PlexPy dashboard. The data ranges from interesting information (most popular movie) to vital server data (most concurrent streams). I'm a bit of a data nerd, so drilling down into each section is something I do on a regular basis. If you're not as interested (or creepy) as me, PlexPy also has a robust notification system. Figure 7 shows the wide variety of notification agents available. I use the IFTTT notification agent, so I get a quick ping on my phone when server events take place. The notification settings can be tweaked to send whatever information you desire. If you want to know every time someone starts playing a video, you can do that. If you just want to be notified if someone starts streaming multiple concurrent streams, you can set that up too. That is of particular interest to me, because if one of my friends suddenly starts streaming my server files to multiple locations, it probably means that account was compromised. Before I got a fiber connection to my office, I also was concerned about upload bandwidth. Now I just want to know when concurrent streaming happens.

Figure 6. I love PlexPy. The sheer amount of data is delicious.

Figure 7. Notifications are important, and the number of options is wonderful.

How to Consume

I've written about this several times through the years, but it makes sense to mention it here as well. Plex has a ton of client options. The web browser interface is robust and available anywhere simply by heading to https://plex.tv/web from any computer. Once authenticated, you'll be connected to your personal server and be able to configure it or watch videos.

There are mobile applications for Android and Apple as well. Unfortunately, if you're not a Plex Pass subscriber, those apps cost $5. The plexmediaserver does a great job of detecting bandwidth issues, so if you're streaming over cell-phone internet, it can dial back the video quality during transcode. Every time I'm on the road for work, I bring a tablet along so I can watch movies and TV from my hotel room. Even with horrible hotel internet, I generally can watch acceptable-quality video.

When it comes to consuming movies and television, however, the television is still king. Quite a few smart televisions have Plex as an installable application out of the box. Samsung smart TVs in particular do a great job, and since Plex is a native app, there's no need for an extra remote. My television brands vary, so native apps aren't always an option. My favorite device for connecting to Plex is a Roku. I have a Roku 4K television in my office, but the standalone Roku boxes work well too. I like Roku because since it's not a streaming content provider, it doesn't favor one application over another. That means Netflix, Hulu, Amazon Video and Plex all are treated the same. And, Plex works very, very well on every Roku device I've tried. Even a Roku Express, which is installed in my Chevy Traverse, works well on long car trips.

If you're not interested in buying new hardware just to connect to a Plex server, chances are you already own something with Plex support. Most modern video game platforms (Xbox, PlayStation) have Plex in the app store. Even a Raspberry Pi works well, and there's a distribution (www.rasplex.com) designed to make a Pi the perfect client.

Perfection? Nothing Is.

As much as I love the Plex platform for media streaming, I'll admit, I wish the plexmediaserver portion was open source. The development team is admittedly very fair with the product and allows anyone to use a significant number of features for free, but it's still not the same as being open source. If that bothers you, Plex might not be something you should check out, because if you do check it out, chances are you're going to love how well it works, and then you'll have a tough decision to make.

I'm okay with supporting a proprietary project, especially when the developers embrace the Open Source community and continue to contribute their code on the front end to the FOSS world. Heck, I'm even willing to give them money in the form of a lifetime Plex Pass subscription, because I really like what they're doing. If you'd like to participate, I urge you to head over to plex.tv and check it out. If nothing else, every blog post comes with a picture of Barkley, the developer's dog.

Shawn Powers is the Associate Editor for Linux Journal. He's also the Gadget Guy for LinuxJournal.com, and he has an interesting collection of vintage Garfield coffee mugs. Don't let his silly hairdo fool you, he's a pretty ordinary guy and can be reached via e-mail at info@linuxjournal.com. Or, swing by the #linuxjournal IRC channel on Freenode.net.

LJ Archive