Table of Contents
  • Home
  • /
  • Blog
  • /
  • Build Your Own OTT Platforms Like Netflix Using Raspberry Pi and Plex Media Server:
February 13, 2024

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

Build Your Own Ott Platforms Like Netflix Using Raspberry Pi And Plex Media Server

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.

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.

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.

Prerequisites for building your own OTT platform like Netflix on a Raspberry Pi using Plex:

  1. Raspberry Pi: You need a Raspberry Pi device with the Raspberry Pi OS installed. The blog recommends first setting up your Raspberry Pi if you haven’t used one before.

  2. Plex Media Server: You need to have the Plex media server application installed on your Raspberry Pi. This is the software that will power your OTT platform.

  3. Storage: You need one or more storage drives connected to your Raspberry Pi to store the media files that will comprise your video/music library. The blog recommends formatting and partitioning these drives properly first.

  4. Networking: Your Raspberry Pi needs to be connected to your local network and/or the internet depending on whether you want internal or external access to your Plex server. This allows streaming and remote access capabilities.

  5. Media files: You need to accumulate media files like videos, movies, TV shows, music etc. in your storage drives that will become your streaming library accessible via Plex.

  6. Client devices: To access the streaming content through your Plex server, you need client devices like smartphones, computers, smart TVs etc. with a Plex app or modern web browser installed. These become your end playback devices.

  7. Accounts: You may want to create user accounts if allowing access to multiple people so they can have their own watch history, playlists, parental controls etc.

Let me know if you need any clarification or have additional questions!

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

How to build your own OTT platforms using Raspberry?

Step 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 repository, see what you will see if you attempt to install it directly from the apt repository.

$ sudo apt-get install plexmediaserver

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

Step 3. How to add repositories to source.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.

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

Step 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

Step 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 public main
deb: A Debian binary repository
URL: Location of the repository
public: Distribution name
main: category of the repository

Step 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 | 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

Step 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

Step 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

Step 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

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

Step 12. Login to the plexmediaserver web
Step 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.

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

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

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

Step 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

Step 18. Move the Library from 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.

Step 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

Step 20. Start the plexmediaserver service

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

$ sudo service plexmediaserver start

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

Step 22. Add Libraries
Step 23. Default categories in Plex

You notice Plex has five default categories to choose from.

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

Step 25. Browse the content 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.

Arun KL

Arun KL is a cybersecurity professional with 15+ years of experience in IT infrastructure, cloud security, vulnerability management, Penetration Testing, security operations, and incident response. He is adept at designing and implementing robust security solutions to safeguard systems and data. Arun holds multiple industry certifications including CCNA, CCNA Security, RHCE, CEH, and AWS Security.

Recently added

Learn More About Cyber Security Security & Technology

“Knowledge Arsenal: Empowering Your Security Journey through Continuous Learning”

Cybersecurity All-in-One For Dummies - 1st Edition

"Cybersecurity All-in-One For Dummies" offers a comprehensive guide to securing personal and business digital assets from cyber threats, with actionable insights from industry experts.



View All

Learn Something New with Free Email subscription