Thursday, February 20th, 2020 10:13 pm
it's not been the best day
So Monday, Mom's best friend died in hospice care, which still feels unreal even though we went to the funeral today. She was only sixty-nine years old. It was hard for Mom; they've been friends over thirty years. I have called one and am waiting for a call from two of my best friends now; that was just way too close. I really needed to hear their voices today.
I think I picked up a mild cold, which ick. But whatever.
Now, more about Plex! Specifically some useful tools once your server is up and running.
Command Line Refresher
'sudo' - 'substitute user do'. This is because you are right now logged in as 'pi', the default, not root. No, don't switch to root, please God. You don't need it and outside very specific circumstances don't want to because you can accidentally delete your entire operating system. I've done that. I've done terrible things with root. Please stay away from root if at all possible. We use 'sudo' instead for commands that only root has permission to do so we don't do that.
'cd' - change directory. Basically 'go to [this directory]'
'ls' - shows everything in that folder.
'-la' - this two separate options for ls. '-l' puts everything in list format; '-a' means to show everything in the folder and everything about the file. You can combine them into a single '-la'
'apt' - 'advanced packaging tool'. It retrieve the information and packages from the authenticated sources for installation, upgrade and removal of packages along with their dependencies. AKa this is the command to install, upgrade, and remove programs.
'get' means get. So 'get advanced packaging tool'. You can now just use 'apt' but if you've been doing linux command line for a while, your fingers refuse to do that yet.
'update' - the command to update sources, either 'sources.list', the list of sources for packages, or the list of sources in the directory /sources.list.d. For 'apt-get' to install or update anything, the location of that package must be in that list or in that folder. Otherwise, you have to use alternate means.
'upgrade' - the command to update your OS. Yes, this confused the fuck out of me with 'update' for a while.
'nano' - this is a text program.
'systemctl' - this is the init and system manager in ubuntu right now. It runs and manages and controls packages.
What is it?
SSH
From the web:
SSH - Secure Socket Shell. This is a network protocol that gives users a secure way to access a computer over an unsecured network. Basically, you can access your media server from your own computer. If you're comfortable with command line and your server is headless (aka no permanent monitor or TV plugged in), it's a very easy way to login and do maintenance or anything else.
SSH comes preinstalled in Pi, so to use it, all you have to do is turn it on in the GUI.
Activate SSH
- In your Pi GUI, open the Menu and go to Preferences, then Raspberry Pi Configuration.
- In Raspberry Pi Configuration, go to the tab labeled "Interfaces".
- You'll see a list of different interface types with radio buttons. Select 'Yes' for SSH.
- You're done.
Why do I want it?
You may not; if you're Pi has a monitor or it's easy to hook it up to one or to your TV, and you hate command line, it's pretty extra for your purposes. However, if you use command line or want to learn to use it or want to practice it, it's perfect.
Now, I want to add something about the SSH port.
SSH and Its Port
SSH's default port is 22; generally, it's advised you change it since that's the port most likely to be scanned by bots, etc if exposed to the internet. My ssh is almost never exposed and when it is, it's only when I'm actively working on something away from home and I shut it down immediately. Changing the port, however, is a good habit to get into.
Here's a couple of links to articles explaining the whys and hows:
How to Change Your SSH Port
How to change your SSH port
I'll do a breakdown here; we're back in command line.
Change your SSH port
- Open a terminal on your Pi desktop or SSH into your Pi.
- Go to the SSH folder
Back in my Plex installation tutorial, I told you /etc is where most configuration files are kept. That's where we are going.
Run the following command:cd /etc/ssh
We are now in SSH's configuration directory. - SSH Configuration Folder
Before we get to the editing, let's look around.
Run the following command:ls -la
You should see several files and maybe a directory or so. You can not care about anything there but one file: sshd_config. That's the dandy right there. - Make a copy of sshd_config
This is standard practice when doing anything with config files, and I learned that the many crashes and installs and nightmares way. So we'll start with making a backup copy.
Run the following command:sudo cp sshd_config sshd_config.backup
What does it mean?'cp' - copy. It literally makes a copy of the first file name to the second file name.
For the copy to work, of course, you need to change the name slightly, so we're adding '.backup' to the end.
Literallysudo cp sshd_config sshd_config.backup - copy originalFileName to newFileName - Open original configuration file to edit
This is going to be the most basic thing ever.
Run the following command:sudo nano sshd_config
You will see a header of roughly three paragraphs commented out. Then you should see this:
# Port 22
Excellent. - Uncomment the port number
Yes, Port is probably commented out here; that's because the default port is 22. Uncomment it--aka remove the '#'. Just set your cursor at the beginning of the line and hit delete. - Pick the new SSH port number
In the first link above, it says the following:ICAAN classifies ports in two three categories:
System/well known ports: 0-1023
User or registered ports: 1024-49151
Dynamic/private ports: 49152-65535
To prevent mis-configuring your server, you should choose a port from the dynamic/private ports range (e.g. 49160, 53425, 64342 and so on).
In the second link, it says this:Save and close the file. Please note that port numbers 0-1023 are reserved for various system services. Hence, I recommend choosing port numbers between 1024 and 65535. Here is a common list of privileged services and designated as well-known ports...[]
There's a table on the second link with restricted ports.
You can pick from any of the above, or go with '2222' if that works for you. Just remember it; write it down or memorize it. - Change the ssh port number
Pretty much what it says. Erase the '22' and put your own choice for port. Then click Ctrl-S and Ctrl-X to save and exit. - Restart ssh
Very straightforward.
Run the following command:sudo systemctl restart ssh
That's it! Next time you log into ssh, enter the new port.
RDP
What is it?
RDP - Remote Desktop Protocol. This is a proprietary protocol developed by Microsoft, which provides a user with a graphical interface to connect to another computer over a network connection. Basically, you connect with Windows Remote Desktop Connection or another program like it and get the entire graphical desktop that you see on your monitor. All from the comfort of your own computer.
Instructions are here:
Raspberry Pi Remote Desktop
This is super useful if you don't have a monitor/tv to devote full time to the Pi or just want to not have to get up and go to your Pi. I love not getting up.
My Pi 4 OS installation apparently had it--at least, I don't remember adding it--but it's super easy to add. This will again be from command line If you installed SSH, we can practice command line with it! Otherwise, open a terminal on your Pi desktop and do the following.
Install RDP
- Update and upgrade your OS. Just like in the earlier tutorial, two commands.
Run the following two commands:sudo apt-get update
sudo apt-get upgrade - Install RDP
Run the following command:sudo apt-get install xrdp - Get the IP of your machine
You can skip this step if you made your Pi's IP address permanent
Run the following command:hostname -I - Open Windows Remote Desktop on your computer.
- Enter your Pi's IP address and Open
You should get the GUI asking for your username/password. You can set both in Remote Desktop later if you want.
Why do I want it?
You now can access your Pi's GUI without stress or need to hook it up to a monitor or TV. That's literally all there is to it. You are no longer forced to make the epic journey to the monitor or have to hook it up to a TV unless something goes wrong during boot or something.
Now, on to Plex itself.
Plex client apps--like the Plex app in FireTV, or the one in your SmartTV, or in Roku, or your browser, etc--are the ones that actually play the media locally and remotely. For reasons, they sometimes have problems with some kinds of files, some resolutions, and some audio streams. Your TV or sound system may also only be able to play certain resolutions and audio. Especially for remote access, you're going to want multiple resolutions. Why?
Transcoding, the thing we must avoid. I'll explain.
Plex and Multiple Versions
Let me give you an example with me:
My TV is 4K, but my Sonos system only plays up to Dolby 5.1. However, in the browser on my computer, it won't play 4K or TruHD or 5.1; the plex desktop app, however, can play 4K plus TruHD. It literally depends on a.) what the machine (TV, computer) can handle and what the client app that is playing your media can do. And when it comes to the client app, that depends on if it was updated and who wrote the code and fuck all. Pretty much like any program.
To make sure your movie can play in any plex app and your browser, you want multiple versions at different resolutions. Further, each of those files should have every audio file available.
Here are some basic tips:
- When ripping source, try to rip it into an 'mkv' file. They're the most universal type.
- When ripping source, get every audio type in either your preferred language or all the languages, whichever, but get every one. Some are voice over for the visually impaired, some may be director commentary, some are movie audio; get them all and make your life easier.
Here's an example from Captain Marvel:
Audio 1: TrueHD
Audio 2: AAC3
Audio 3: Dolby Digital 5.1 Surround
Audio 4: AC3
Audio 5: AAC LC
Jupiter Ascending:
Audio 1: TrueHD
Audio 2: AAC LC
Audio 3: Dolby Digital 5.1 Surround
Audio 4: Dolby Digital 5.1 Surround
Audio 5: AAC LC
Audio 6: Dolby Digital 5.1 Surround
Audio 7: AAC LC
I didn't pick and choose; if it was English, I grabbed it for my rip. - Most 4K movies come with a 1080p bluray. Rip both and get full audio/subs on both.
- Create a 720p version with all audio and encode in H.264.
This is outside the scope of right now, but I will do an entry on Handbrake, and what I personally use when encoding a 720p version of a movie (and a 1080p for that matter). However, any video editing program is probably fine. H.264 is still the general standard for most video encoding. You can use H.265 or V8/V9, but your Plex app may be cranky about it. - Use Plex naming standard to identify them.
Links
Naming Plex Movies
Multi-Version Movies
This one is pretty easy since Plex has a whole section on naming your movie, tv, etc files. This is how you get the resolution into that so it can be selected manually or by the Plex client app.
Naming standard for movies:
[Movie Name][Year].[ext]
Naming standard for movies with resolution:
[Movie Name][Year]-[Resolution].[extension]
Example:
Captain Marvel(2019)-4K.mkv
Captain Marvel(2019)-1080p.mkv
Captain Marvel(2019)-720p.mkv
That '-' makes it possible. Anything after the dash, provided it recognizes the movie, will not be read by Plex as part of the name. You can put more in there, actually--encoder, audio, etc--but first, to get it to show up under Version, put the resolution.
Options:
4k, 1080p, 720p, 480p, 480i, SD
Doing this makes it possible to pick what resolution you want--each app has a different place but it's usually under version--or let the Plex app playing it can pick the on it can play.
Here are some of my files:
captain.marvel.2019-720p.V9CQ184K.mkv
Note: the '.' is my choice instead of spaces and paretheses since I do a lot of my work in command line.
Now, look at everything after the dash
'-720p' - that's the resolution of the movie. That must be the first thing after the dash to get movie resolution versions in any Plex client app.
'.V9' - this is the video encoder. This is just for me when I was experimenting with encoders.
'CQ18' - this was the constant quality setting in Handbrake I used for 720. Again, this is info just for me.
'4K' - this was the resolution of the source file I used to create the 720p. - Put all the versions in the same folder.
Example:
Folder: /media/pi/movies/Captain Marvel (2019)
Files:
Captain Marvel (2019) - 4K.mkv
Captain Marvel (2019) - 1080p.mkv
Captain Marvel (2019) - 720p.mkv - For audio, you don't need a separate file for each type of audio; each file resolution should have all of them. The app will pick, or you can manually pick any one of them.
To see this yourself, after adding/creating a second resolution of a movie with multiple audio streams and adding it to that movie folder, go to your browser, go to Plex, and click on the movie.
On the main screen, you'll see audio is now a drop down, and you can select another audio type.
To find Resolution, however, go to teh top right, to the three vertical dots right of the pencil and click on those dots; the first entry in the drop down is 'Play Version'. Click on that.
A popup will display tilted "Play Version' with two or more of these (depending on the resolutions of those movie files):
XX Mbps - 4K
XX Mbps - 1080p
XX Mbps - 720p
XX Mbps - 480p
XX Mbps - SD
Happy plexing!