• Home
  • |
  • Blog
  • |
  • 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 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.

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?

  1. 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.
  2. 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.
  3. 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.

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

Time needed: 30 minutes.

How to build your own OTT platforms using Raspberry?

  1. 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 plexmediaserverInstall plexmediaserver on raspberry pi

  2. 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.Standard Repositories in Raspberry PI

  3. 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.Repositories entries in Raspberry PI

  4. 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.Standard Repositories in Raspberry PI 2

  5. 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.listCreate a new file called plexmediaserver.list

  6. 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 repositoryAdd the repository

  7. 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 commandInstall plexmediaserver on raspberry pi

  8. 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 updateinstall apt-transport-https package

  9. 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 plexmediaserverInstall plexmediaserver

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

    $ sudo service plexmediaserver statusCheck the plex services

  11. This ends the installation session.  Now let’s see how to configure the Plex media server.

  12. 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.Browse plex service on the browser

  13. signup plex service

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

  15. 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.Plex server setup 2

  16. 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 server setup 3

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

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

    Stop Plex service

  19. 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.
    Move plex library to the hard drive

  20. 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
    Create a symbolic link of plexmediaserver directory

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

    $ sudo service plexmediaserver startStart plex service

  22. 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.Plex library

  23. Add Plex library

  24. You notice Plex has five default categories to choose from.Default plex media categories

  25. 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 contents to Plex library

  26. Add folders to Plex library

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.

About the author

Arun KL

To know more about me. Follow me on LinkedIn Hi All, I am Arun KL, an IT Security Professional. Founder of “thesecmaster.com”. Enthusiast, Security Blogger, Technical Writer, Editor, Author at TheSecMaster. To know more about me. Follow me on LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Learn Something New with Free Email subscription

Email is also one of the ways to be in touch with us. Our free subscription plan offers you to receive post updates straight to your inbox.