Raspberry Pi is increasing its capabilities with its developing computing power with the passing of time. Its small size with less price makes it awesome too to use in many digital projects. We feel excited to share information about one such digital project. Yes, we are going to show you how you build your own OTT platform like Netflix using Raspberry Pi in this blog. There are different ways to do this. And, there are several third-party products are available in the market to help you do this. Some of them are free and some of them come for a price. In this blog, we are going to show you how to build an advanced, futuristic media server using the Plex media server.
Contents
What is OTT?
OTT stands for Over The Top media service. OTT is a media service that provides on-demand TV shows, movies, web series, and music over the internet. Unlike in traditional broadcast system, OTT content can be watched on any computers, smartphones, smart TV, gaming consoles, pretty much anything which has a web browser with an internet connection. Perfect examples for OTT services are Netflix and Amazon prime videos.
In addition to that, the OTT platform indexes and catalogue the media files like pictures, audio, and video for you to play. You can just send your queries and get the results on your screen. As an example, Search your favourite TV show, search for the movie you want to watch, and you can search all the songs by a singer or an artist. All these additional capabilities make the media server more user friendly, easier to manage, and more attractive to the user. That’s the reason it is gaining more attraction these days.
What is Plex?
Before we directly jump in to see how to set up the Plex media server on a Raspberry Pi, we would like to share some information about the Plex. Plex is a fully-featured media server. It offers a lot of advanced features which you may not see in other media servers such as streaming directly to a browser. It provides an attractive web frontend not only for Plex clients but also for Plex admins to configure the Plex. Transcode is the best feature we found in the Plex, which offers freedom of media conversion on the run. Plex supports pretty much any devices you own, like, smartphones, smart TVs, Firesticks, smart set-top box, Xbox, and many more. All these supports plenty of different frame size and formats. Transcode plays a magical role in order to support devices that even can’t play a file in its original format. For instance, if you have some media files that you can’t play on your Xbox 360. Plex can translate those files on the fly into a format that Xbox understands so you can watch them.
The second feature I found very much needed is its way of optimizing the stream. Plex is intelligent enough to use a lot of compression and decoding techniques to support the varies types of the client which demand the stream. For instance, if your internet connection goes slow down suddenly for any reason while you are watching a movie on your smartphone, From that movement, you start receiving the lower quality of the stream to better optimize the network bandwidth. Basically, the more capable the devices you use to watch the videos, the better the things will go.
At last, We would also like to tell you that Plex is not just limited to your home network. You can use it to stream your media on the internet. This allows you to enjoy your media wherever you are. Your media is always at your fingertips. All you need is a computer with your media files stored and a Plex server running on it. Let’s explore how you set up your media server step by step on a small computer like Raspberry Pi in this tutorial.
What is Required To Build Your Own OTT Platforms On A Raspberry Pi?
- A running Raspberry Pi with Raspberry PI OS, Plex media server app installed on it. Please check out our posts “How easy to set up Raspberry Pi:” and “Five easiest ways to connect Raspberry Pi remotely in 2021:” if you are working on the Pi for the first time.
- Your choice of clean formatted and partitioned storage drives connected to Pi to store media files. Please check out our post “How to Partition and Format the Hard Drives on Raspberry Pi:” to know more about adding a hard drive to a Raspberry Pi.
- We also recommend you to read this post “How to set up a personal cross-platform file server on Raspberry Pi” prior to starting this mini project. This post gives a background of our directory file structure on which we are going to build a Plex media server.
How To Set Up A Plex Media Server On A Raspberry Pi?
In this section, we are going to cover how to set up a fully-featured cross-platform Plex media server. We have divided this section into four major subsections which would give you a better understanding of the complete setup process.
- Installation
- Configure Plex media server
- Set up media directories
- Start Streaming media
Time needed: 30 minutes.
How to build your own OTT platforms using Raspberry?
- Installation
The installation procedure is quite different in the case of the Plex media server as it is not part of the apt repositories. So the regular apt install method won’t work here. If you try installing the Plex media server in a regular way like other apt packages, apt simply won’t understand what you want to install. Because it isn’t part of the standard raspberrypi.org repository, see what you will see if you attempt to install it directly from the apt repository.
$ sudo apt-get install plexmediaserver
-
We would like to give some heads up on the standard repositories. If you see the content of the apt directory, you will see a file called sources.list. This file contains the list of repositories where the apt can look to pull the packages for installation.
-
Open the sources.list to see the repository details. If you see the content, it has multiple lines each line specify a repository. The line that starts from the ‘#’ symbol is considered a comment. apt don’t consider that as a repository. Let’s tell you how to read the content of each repository. Each repository is broken into multiple parts. In this example, the first ‘deb‘ represents it’s a debian binary repository. If you scroll down to the third line it starts with ‘deb-src’ which means it’s a debian-source repository. Back to the first line. the second marked box which starts with http:// is a repository link, the third ‘buster’ is the repository distribution, and the last box contains few keywords, they are all categories created of the repository. We hope this is much more clear now.
-
Plex maintains its own repository we just need to tell apt where it is so that it can install the packages from there. The idea is to add the Plex repository to sources.list file. This would let apt to know from where Plex packages could be downloaded and installed. But, there is a better approach to do this. The apt directory contains a directory called ‘sources.list.d’. If you look in there, there are other .list files that contain the repositories of other applications.
-
Create a new file called plexmediaserver.list there which will tell apt from where the Plex packages are available for download.
$ sudo nano /etc/apt/sources.list.d/plexmediaserver.list
-
Add the repository as like other repositories that we have shown above. Write this line and exit nano:
deb https://downloads.plex.tv/repo/deb public main
deb: A Debian binary repository
URL: Location of the repository
public: Distribution name
main: category of the repository -
Next, we need to install the signing key to the repository as the Linux packages are cryptographically signed the packages they release so that the client computer can verify the contents. Issue the below command to download and install the key.
$ curl https://downloads.plex.tv/plex-keys/PlexSign.key | sudo apt-key add –
curl: A command which transfers the file from the internet
Symbol ‘|’: A pipe that servers as a bridge between two commands. It takes the output of the 1st command and serves it as an input to the 2nd command.
apt-key: It’s an apt-key management command -
There is one last thing before we install Plex. Please make sure ‘apt-transport-https’ package is installed. This package is required as the plex repository uses a secure channel ‘https’ to download the packages. Use the normal apt command to install the HTTPS transport package.
$ sudo apt-get install apt-transport-https
Tell apt to update the list of software packages so that it can update the packages from the newly added Plex repository.
$ sudo apt-get update
-
Now the apt knows about the Plex repository and you can install the Plex media server like we would any other packages. It may ask you to update the repository file during the installation process to fetch the new packages. Say ‘yes’ to it and keep continue with the installation procedure.
$ sudo apt-get install plexmediaserver
-
Check the plex services has started successfully. You should see the service is up and running if everything goes well.
$ sudo service plexmediaserver status
-
This ends the installation session. Now let’s see how to configure the Plex media server.
- Configure Plex media server:
We are not going to set the configurations by editing the configuration files by hands, Instead, we are going to handle configurations through a web interface.
Open the browser on your Raspberry Pi and type ‘localhost:32400/web’ in the address bar of the browser. You can also do this from your other desktop. Type the IP address instead of localhost there.
You may see a variety of different options to register and create your account. Sign up with your account is what makes it possible to use your server from other Plex clients.
Note: Don’t forget to add /web otherwise you may end up in some error. -
Leave this option unchecked if you want to use the Plex only inside your home. We will leave this option checked and hit next.
-
You are going to see the Library setup page. Just skip this session for now as there is some setup that we need to do first.
-
Next, it asks you to download software for your clients. You can download the apps later as well, there is no hurry. Click Done.
-
Plex allows you to configure almost everything from its web interface with one notable exception. At the present time, there is no UI for changing the directory where the plex can store database, thumbnail images and other metadata files. This may come in later versions, but now, Linux will store all these underneath the /var/lib/plexmediaserver directory. This directory is on our SD card. We just don’t want to keep this data on the SD card. The irony is, we don’t see any settings to change this at this time as this seems to be hardcoded inside the Plex itself. Don’t be worry so much, there is a way to solve this problem. Move the content of the plexmediaserver from the SD card to the hard drive. And, create a symbolic link on the SD card. Let’s show you this practically.
-
The first and foremost thing is to stop the ‘plexmediaserver’ service and kill all the process running by the user ‘plex’. Idea is to stop all process owned by the user ‘plex’. Nothing should be writing to the files we are going to transplant.
$ sudo service plexmediaserver stop
$ sudo killall -u plex -
Move the existing library directory /var/lib/plexmediaserver/ from the SD card to the hard drive where we have plenty of space to store.
$ mv /var/lib/plexmediaserver/ /mnt/data-ext4/plexmediaserver/
Check the content of the plexmediaserver directory. You should see a ‘Library’ directory underneath. Now you have the library on your hard drive.
-
Create a symbolic link of the plexmediaserver directory under /var/lib/ on the SD card. It just works as it is a local directory. Plex never knows the difference.
$ sudo ln -s /mnt/data-ext4/plexmediaserver/ /var/lib/plexmediaserver
-
Start the plexmediaserver service back again. Make sure the service is up and running.
$ sudo service plexmediaserver start
- Set up media directories:
Log in to the web as like earlier. Type ‘localhost:32400/web’ to login to the Plex web on the Pi. Upon sign in to the Plex. Go to your profile and start setting up the media directories. Click on manage libraries. And, add library.
-
You notice Plex has five default categories to choose from.
-
We are going to add Movies first by clicking on the Movies icon. Browse the directory where you have movies stored on your hard drive.
Note: Please make sure you have all the permissions required to work on the media directories. When you are working on the Linux file system, it is necessary to know about the permissions. We have covered the permissions in our “How to set up a Raspberry Pi as a media server using miniDLNA” post. We are not going to repeat the session again to shorten the tutorial. Please read that post to learn about the permissions.
Add all other media directories to the library. As a personal suggestion, please follow the naming standards when you are dealing with TV shows and pictures. There are a couple of advantages in doing this. This helps your Plex server to fetch the content about the TV shows/movies from the internet. And, This increases your indexing experience much better.
You may need to enable the auto-scan library to work it on your server. In order to enable the auto-scan option. Go to settings, go to Library and check the option ‘scan my library automatically’. The scan process would take some time depending on your media collection. Once the scanning and indexing process is complete, your Plex media server is ready to stream your media on other devices over the network.
This is how you can build your own OTT platforms like Netflix using Raspberry Pi and Plex media server.
Thank you for reading this article. Please visit the below links to read more such interesting articles.
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/269949.html