Build Your Own OTT Platforms Like Netflix Using Raspberry Pi and Plex Media Server:

Arunkl
TheSecMaster
Published in
12 min readDec 5, 2022
An image of Raspberry Pi and PLEX Media with black background
Source: thesecmaster.com

Raspberry Pi is increasing its capabilities with its developing computing power with time. Its small size with lower price makes it awesome too to use in many digital projects. We feel excited to share information about one such digital project. Yes, we will 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 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 will show you how to build an advanced, futuristic media server using the Plex media server.

Table of Contents

· What is OTT?
· What is Plex?
· What Is Required to Build Your Own OTT Platforms on a Raspberry Pi?
· How to Set up a Plex Media Server on a Raspberry Pi?

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 traditional broadcast systems, OTT content can be watched on any computer, smartphone, smart TV, gaming console, or pretty much anything which has a web browser with an internet connection. Perfect examples of OTT services are Netflix and Amazon prime videos.

In addition to that, the OTT platform indexes and catalog 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 for your favorite TV show, search for the movie you want to watch, and you can search for 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 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 device you own, like, smartphones, smart TVs, Firesticks, smart set-top boxes, Xbox, and many more. All these supports plenty of different frame size and formats. Transcode plays a magical role in supporting devices that 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 various types of clients which demand the stream. For instance, if your internet connection slows 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 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.

An image shows the Plex Media Server, which connects different types of devices
Plex Media Server, which connects different types of devices

What Is Required to Build Your Own OTT Platforms on a Raspberry Pi?

  1. A running Raspberry Pi with Raspberry PI OS and 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.
  2. Your choice of clean formatted and partitioned storage drives is connected to a Pi to store media files. Please check out our post “How to Partition and Format the Hard Drives on Raspberry Pi:” to learn more about adding a hard drive to a Raspberry Pi.
  3. We also recommend you read this post, “How to set up a personal cross-platform file server on Raspberry Pi,” before 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.

  1. Installation
  2. Configure Plex media server
  3. Set up media directories
  4. Start Streaming media

The time needed: 30 minutes.

How to build your own OTT platforms using Raspberry?

  1. Install Plexmediaserver on Raspberry Pi

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

An image trying to install the Plex Media Server directly from the apt repository.
Trying to install the Plex Media Server directly from the apt repository.

2. Add the repositories to install the packages

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.

An image to navigate to sources.list file under apt directory
Navigating to sources.list file under apt directory

3. How to add repositories to sources.list

Open the sources.list to see the repository details. If you see the content, it has multiple lines; each line specifies 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 the 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 a few keywords; they are all categories created of the repository. We hope this is much clear now.

An image to add repositories to sources.list file
Adding repositories to sources.list file

4. Content of source.list.d

Plex maintains its repository. We just need to tell the apt where it is so they can install the packages there. The idea is to add the Plex repository to sources.list file. This would let apt know where Plex packages could be downloaded and installed. But, there is a better approach to doing this. The apt directory contains a directory called ‘sources.list.d’. If you look in there, other .list files contain the repositories of other applications.

An image of content of sources.list.d file
Content of sources.list.d file

5. Create a file that stores the repository info

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

An image to create a file to store the repository info
Creating a file to store the repository info

6. Content of plexmediaserver.list file

Add the repository to 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

An image shows the content of plexmediaserver.list file
The content of plexmediaserver.list file

7. Install the signing key to 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 serves 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

An image to Install the signing key to the repository
Install the signing key to the repository

8. Install the HTTPS transport package

There is one last thing before we install Plex. Please make sure the ‘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

An image to Install the HTTPS transport package
Install the HTTPS transport package

9. Install the Plexmediaserver on the Pi

Now the apt knows about the Plex repository, and you can install the Plex media server like we would any other package. 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

An image to install the Plexmediaserver on the Pi
Installing the Plexmediaserver on the Pi

10. Check the status of plexmediaserver service

Check the plex services have started successfully. You should see the service is up and running if everything goes well.

$ sudo service plexmediaserver status

An image to verify the Plexmediaserver service status after installation
Verifying the Plexmediaserver service status after installation

11. Configure Plex media server:

We are not going to set the configurations by editing the configuration files by hand, 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. Signing 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.

An image to configure  the Plex media server from the browser
Configuring the Plex media server from the browser

12. Login to the plexmediaserver web

An image to Login to the plexmediaserver web from the browser
Login to the plexmediaserver web from the browser

13. Set up Plexmediaserver to work over the internet

Leave this option unchecked if you want to use the Plex only inside your home. We will leave this option checked and hit next.

An image to configure the Plex media server to access from internet
Configuring the Plex media server to access from internet

14. Skip the Library set up at this time

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.

An image to skip the library configuration and proceed next
Skip the library configuration and proceed next

15. Click Done and ask clients to download the client program

Next, it asks you to download software for your clients. You can download the apps later as well; there is no hurry. Click Done.

An image to click on ‘Done’ to complete the configuration wizard
Click on ‘Done’ to complete the configuration wizard

16. Click Done and ask clients to download the client program

Plex allows you to configure almost everything from its web interface with one notable exception. Currently, there is no UI for changing the directory where the plex can store the 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 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.

17. Stop the ‘plexmediaserver’ service

The first and foremost thing is to stop the ‘plexmediaserver’ service and kill all the processes running by the user ‘plex’. The idea is to stop all processes owned by the user ‘plex’. Nothing should be written on the files we are going to transplant.

$ sudo service plexmediaserver stop
$ sudo killall -u plex

An image to stop the ‘plexmediaserver’ service and Kill all Plex-related processes
Stop the ‘plexmediaserver’ service and Kill all Plex-related processes

18. Move the Library from the SD card to Hard Drive

Move the existing library directory /var/lib/plexmediaserver/ from the SD card to the hard drive, where we have plenty of space to store it.

$ 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.

An image to move the existing library directory from the SD card to the hard drive
Moving the existing library directory from the SD card to the hard drive

19. Create a symbolic link of the plexmediaserver

Create a symbolic link of the plexmediaserver directory under /var/lib/ on the SD card. It just works as if it is a local directory. Plex never knows the difference.

$ sudo ln -s /mnt/data-ext4/plexmediaserver/ /var/lib/plexmediaserver

An image to create a symbolic link of the plexmediaserver
Creating a symbolic link of the plexmediaserver

20. Start the plexmediaserver service

Start the plexmediaserver service back again. Make sure the service is up and running.

$ sudo service plexmediaserver start

An image to start the plexmediaserver service
After symbolic link creation, start the plexmediaserver service

21. Set up media directories:

Log in to the web earlier. Type ‘localhost:32400/web’ to log in to the Plex web on the Pi. Upon signing in to the Plex. Go to your profile and start setting up the media directories. Click on manage libraries. And add a library.

An image to configure the Media directories by clicking ‘Manage Libraries’ in Plex web on the Pi
Configure the Media directories by clicking ‘Manage Libraries’ in Plex web on the Pi

22. Add Libraries

An image to click on ‘Add Library’ to continue
Click on ‘Add Library’ to continue

23. Default categories in Plex

You notice Plex has five default categories to choose from.

An image of the default categories exist on the library
Default categories exist on the Library

24. Add content to the categories

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 ensure you have all the permissions required to work on the media directories. When 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 to shorten the tutorial. Please read that post to learn about permissions.

An image to add the contents under respective categories
Adding the contents under respective categories

25. Browse the content to add to the categories

An image to browse and select the contents to add to the categories
Browse and select the contents to add to the categories

Add all other media directories to the library. As a personal suggestion, please follow the naming standards when dealing with TV shows and pictures. There are a couple of advantages to doing this. This helps your Plex server to fetch the content about 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. 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 can 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.

This post is originally published at thesecmaster.com.

We thank everybody who has been supporting our work and request you check out thesecmaster.com for more such articles.

--

--