Instructions: How to Build Plex Media Player on Raspberry Pi 4 B Under Raspbian

Hi All,

Please bear with me if formatting is shocking, first post on these forums, so I’ll likely need to come back and re-format this post a couple times.

I recently (finally) managed to perform a Plex Media Player build and have it working reliably on my Raspberry Pi 4 Model B 2GB, so though I’d share the steps I found work reliably (so far).

Disclaimer: I am far from a programmer, so these are just the instructions which worked for me. I’m just a little old senior engineer in servers & storage, not Linux/programming. I performed the following on a Raspberry Pi 4 Model B 2GB - I suspect that it won’t run very well on a 1GB model, but would run nicely on a 4GB model.

So, I assume you’ve done the following:

  1. Installed the “Raspbian Buster with Desktop” OS on your SD card (not full featured desktop).
  2. Run through the initial config, set your hostname etc.
  3. Updated the operating system with then “sudo apt-get update” and then “sudo apt-get full-upgrade” commands.
  4. Set your GPU memory size to something reasonable (I used 512MB as this seemed happy).
  5. Turned off the screen sleep after x minutes by adding “xserver-command=X -s 0 dpms” to the [Seat:*] section of the file “sudo nano /etc/lightdm/lightdm.conf” (when PMP is playing, the screen still goes to sleep).
  6. Checked that video and audio is working as expected on your TV/monitor/whatever.

Now to the nitty gritty. Firstly, install the required dependencies for the upcoming build/installs:

sudo apt-get install -y autoconf automake libtool libharfbuzz-dev libfreetype6-dev libfontconfig1-dev libx11-dev libxrandr-dev libvdpau-dev libva-dev mesa-common-dev libegl1-mesa-dev yasm libasound2-dev libpulse-dev libuchardet-dev zlib1g-dev libfribidi-dev git libgnutls28-dev libgl1-mesa-dev libsdl2-dev cmake python3 python python-minimal git mpv libmpv-dev

So you’re aware what the packages are:

autoconf automake libtool libharfbuzz-dev libfreetype6-dev libfontconfig1-dev libx11-dev libxrandr-dev libvdpau-dev libva-dev mesa-common-dev libegl1-mesa-dev yasm libasound2-dev libpulse-dev libuchardet-dev zlib1g-dev libfribidi-dev git libgnutls28-dev libgl1-mesa-dev libsdl2-dev cmake`

These are the dependencies listed in the README at GitHub - plexinc/plex-media-player: Next generation Plex Desktop/Embedded Client

python3 python python-minimal

These are extra dependences missed in the README for PMP

git mpv libmpv-dev

Git is needed to download from git, while mpv is needed because I can’t be bothered building MPV from source.

Now instead of build QT5 from source, again being lazy, we can install QT5 from a package the lovely kiendv has already made for us (see: GitHub - koendv/qt5-opengl-raspberrypi: Qt5 with desktop OpenGL on a Raspberry Pi 4):

wget https://github.com/koendv/qt5-opengl-raspberrypi/releases/download/v5.12.5-1/qt5-opengl-dev_5.12.5_armhf.deb
sudo apt-get install -y ./qt5-opengl-dev_5.12.5_armhf.deb
rm qt5-opengl-dev_5.12.5_armhf.deb

Finally, we can build PMP:

mkdir ~/pmp
cd ~/pmp
git clone git://github.com/plexinc/plex-media-player
cd plex-media-player/
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DQTROOT=/usr/lib/qt5.12/ -DCMAKE_INSTALL_PREFIX=/usr/local/ ..
make -j4
sudo make install

Note the double dots at the end of the cmake line.

After this, Plex Media Player will appear in the Application menu in the GUI, or you can run it from terminal just by running

plexmediaplayer

I needed to run it once from terminal to set it to TV mode and fullscreen, but after this it remember those settings for me:

plexmediaplater --fullscreen --tv

As an example of how things are performing, I’m currently playing a HD channel from Live TV (I have the DVR feature) and htop is showing:
CPU: All cores average around 45%
Memory: 635M used of 1.89G
Swap: Unused

It looked exactly the same when playing 1080p videos at 60fps. I don’t have 4k or any 4k videos to test with, sorry!

Bon appetit.

12 Likes

I have plenty of Pi’s but I’ve never used one as a Plex player. Is this something that is not an out of the box solution? I guess I’m asking because I don’t know what the advantage is here compared to using a 4K Firestick or similar which can natively play Plex via as well as all the other streaming services like NetFlix etc. On sale they are cheaper than a Pi4 1GB.

I think it’s cool and I may try it just to say I did it, but is there a reason that you figured this out? Were you trying to achieve a goal not obtainable any other way?

Since this is a “full PMP”, it doesn’t suffer the many limitations of other hardware players and their respective Plex apps.
Pixel-based subtitles: no issue direct-playing them
SSA/ASS subtitles (mainly used in Anime fan-subs): no issue direct playing them
selected the second audio track + subtitles: no forced transcoding
etc. pp.

Plus the better customizability of PMP.

2 Likes

Nah, fair questions mate.

So, while a solution does/did exist called RasPlex, which uses OpenPHT, but there’s two issues:

  • It’s not been updated since March 2017, so doesn’t work on the RPi4
  • OpenPHT doesn’t/didn’t have DVR/LiveTV support, so won’t work for me (we use the DVR a lot)

Other than that, Plex no longer support the Raspberry Pi because there’s just not enough demand (as you said, a 4K Firestick is cheaper, as are other options).

The only advantages, to be honest, are that I can fiddle with it and have full control. I’m also installing Kodi with the “Aussie Addons” to enable a nice streaming interface for our free-to-air channels that provide after-airing streaming (e.g. ABC iView, SBS On Demand, 9Now), and am looking at setting up emulators (like RetroPie) for some fun retro gaming, but without having to dedicate the whole RPi4.

The tl;d form is essentually “Because I can” :slight_smile:

Edit: Also of note, OttoKerner is correct in his post (he got it up while I was writing the last one), it’s the full featured PMP. Forgot to mention that!

2 Likes

All cool stuff! I hadn’t thought about the emulator multi-purpose option.

Because we use a lot of streaming services I can’t get rid of my Firesticks/Rokus/Shields. The main reason I use a Pi for streaming at all is for running LibreELEC. I run that because it’s the only package I’m aware of that can play 3D-MVC that is open source and free. All the hardware players I know of are $$$ and use proprietary software. Using LibreELEC with the “Plex for Kodi” add on I can get a more plex-like interface, use all my own Plex accounts and still play 3D-MVC.

I’m curious if something like this could ever be used to support 3D-MVC in ACTUAL Plex? From following the LibreELEC forums it seems that although 3D-MVC works fine on the Pi3 platform, the Pi4 is held up by not yet using the 5.X Linux kernel which will allow them to use advanced video drivers on the Pi4, therefore, make 3D-MVC work. I’m already using the Pi3 for this purpose, but the tradeoff is no HD audio or 4K. 3D video in itself is not more than 1080, but I want ONE solution.

I have a few questions…

Would this work with an internet outage unlike the firestick, roku… or does it require Plex.TV connection to work…

Could it be configured to work remotely without a Plex.TV account…

You see where I’m heading… Thanks…

It is PMP. So it works just like every other Plex client, connection-wise.
Once signed in to your plex account, it will work for a while offline (if it can find your server) and if you don’t require subsequently a user switch/user authentication.

Thanks for the reply…
Ok so it won’t work… for what I want to do…

Basically a Plex client to hook to TV’s and not have to use Plex.TV… local and remote

I would even get a static public IP if needed…

So I always manually specify my Plex Server in the setting of PMP, just out of habit for it the internet goes down/whatever. That’s set in PMP by going to [Name] > Settings > Manual Servers > Connection 1 IP and putting in IP, and leaving port as 32400 if default, or something else if not.

Having this set, I just tested this by pulling the plug from my router to my switch (i.e. cutting the internet), and I was still able to browse and play without issues. This included a reboot of the RPi4, i.e. a restart of PMP.

From what I understand, if you don’t set the manual server, it (should?) get the internal details from plex.tv and if the internet is lost, still connect internally using that cached information. The problem there being, if there’s no internet when PMP is started, no internal connection, but if the server is manually set then it’ll work without internet all the time.

That said, if someone who knows better than me knows different, please correct me!

1 Like

Hi. Thank you for instructions on PMP. Build O.K. but after nice starting I receive this error on attempt to play anything :
[1:1:0402/233105.337347:ERROR:render_media_log.cc(30)] MediaEvent: PIPELINE_ERROR DEMUXER_ERROR_COULD_NOT_OPEN
[1319:1352:0402/233118.199413:ERROR:ssl_client_socket_impl.cc(1050)] handshake failed; returned -1, SSL error code 1, net_error -100
[1319:1352:0402/233118.266777:ERROR:ssl_client_socket_impl.cc(1050)] handshake failed; returned -1, SSL error code 1, net_error -100
Failed to open VDPAU backend libvdpau_vc4.so: cannot open shared object file: No such file or directory
plexmediaplayer: …/video/out/opengl/utils.c:87: gl_upload_tex: Assertion `stride > 0’ failed.
Aborted

1 Like

Hi mate,

I think that error is related to it trying to use opengl, which isn’t available on the RPi4 (I think). Like I said, I’m no program or Linux pro.

Maybe try changing settings in PMP or on the Plex server to transcode at the server and not the client? Also check that you installed qt5 properly.

I do recall running into that error on one build, but it was when I was trying to compile qt5 myself instead of using the download link in my original post.

1 Like

OK. Thank you.

Hey mate, I’ve just bought Pi 4B and I followed your instructions to install Plex Player. I succeded, but the Raspberry has really hard time to play anything. I’m not sure what I’m doing wrong. It just stutters so badly. I’ve set GPU memory to 512. I’ve checked htop command to see if CPU is maxed out, but it just goes around 60%, then boom 99% - plex player freezes, then back to 60% and plex “only” stutters. Could it be caused by slow SD card? I’ve ■■■■■■ class 6 card. Temps are not problem too. I’m desperate, I’ve been looking forward to make my TV play from my Plex library, but I’ve been trying to run this all afternoon and still no luck. I was trying to play 1080p x265 file.
Also thanks for this epic guide!

1 Like

Any reason this shouldn’t work on the pi 3 / b /b+? I’m doing custom voice commands so I need something more than the stock libreelec that the official PMP is built on.

Hi mate, I think that it should work, as long as you’re able to source aQT5 install with Web Engine etc. for RPi3 (the installer I use here for QT5 is only for the RPi4), then the rest should work.

When you compile PMP, it’ll tell you if there’s any plugins for QT5 or other packages missing/unable to be found. Just check the logs.

@vojtajk_plex_gmail_com Hi mate, sorry about the slow response. I’m not 100% sure what the issue could be there.

What are you using to monitor the stats? If not already, SSH into the RPi4 and use htop, then run Plex in the GUI and it’ll show what’s going on/which services are using how much resource. I’ve found that after running a while on mine, PMP tends to creep up it’s RAM usage quite a bit until it uses 100% RAM and then goes into swap space. I increased swap space to 4GB (I have a large SD card) and setup a cron job to reboot the RPi4 every night (hackity hack, I know).

Other than that, maaaybe look at if it’s transcoding on the RPi4 instead of on the server? Check settings around that I guess?

Well just to confirm, this method works currently on the pi4 still.

Will give it a rattle on the pi3 soon

Hi,
I was able to instal PMP using the instructions, just one question, how to configure Raspbian to autostart PMP?
Thanks

Good to hear mate! Did you have any luck on the RPi3? Curious to give that a go at some point myself.

G;day mate, there’s a few guides out there on how to start an application at login - assuming you have Respbian configured to login at boot - and there’s a lot of ways to do it. This might be of help: https://www.dexterindustries.com/howto/run-a-program-on-your-raspberry-pi-at-startup/

1 Like