Installing Plex Docker on Raspberry Pi 4 and a Brief Test

First of all, during this epidemic, I hope everyone is safe.

Today I received a Raspberry Pi 4, and since I already have a mini host with Plex service installed, I wanted to test if the Raspberry Pi 4 can smoothly run Plex. So I decided to give it a try. Oh, I'm running it with Docker, this article includes instructions on installing Docker, pulling the Plex image, configuration, the entire playback process, and then a brief test.(English version Translated by GPT-3.5, [返回中文](../20200208-test-raspberry-pi-4-plex))

Introduction

  1. The test videos include the following, which should cover most scenarios:

    1. Detective Conan: The Fist of Blue Sapphire BDMV Remux H.264, True HD Audio 18GB MKV
    2. Detective Conan Episode 993 The Conspiracy at the Food Court H.264, AAC 227MB MP4
    3. Detective Conan: The Zero Enforcer BDRip H.265(HEVC), Flac 5.6GB MKV
    4. Natsume's Book of Friends Season 4 Episode 6 The Other Side of the Glass H.264 10Bit(10Bit is mentioned when I downloaded it) AAC 160MB MKV
    5. Love, Death and Robot H.265, Ec-3 650MB MP4
    6. Zootopia BDRip H.264 DTS 16GB MKV
  2. I’m using the 4GB version of the Raspberry Pi 4.

Cat CPUInfo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
root@raspberrypi:~# cat /proc/cpuinfo 
processor : 0
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 144.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3

processor : 1
...

processor : 2
...

processor : 3
...

Hardware : BCM2835
Revision : c03111
Serial : 10000000c1e9032e
Model : Raspberry Pi 4 Model B Rev 1.1

Free -m

1
2
3
              total        used        free      shared  buff/cache   available
Mem: 3906 167 3068 8 670 3606
Swap: 99 0 99

Installing Docker

One command is all you need

Installing Docker is very simple, just one command, as for the waiting time… (I recommend using a VPN)

1
curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh

Docker Accelerator

Before that, I need to get a Docker accelerator from Alibaba Cloud, otherwise, waiting for the image to be pulled from the official website will be frustrating.

  1. Log in to Alibaba Cloud - Container Registry

    login-aliyun

  2. Then just copy the following shell script, Aliyun has already replaced the address for us (you can also use DaoCloud Mirror for acceleration)

    copy-shell

    1
    2
    3
    4
    5
    6
    7
    8
    sudo mkdir -p /etc/docker
    sudo tee /etc/docker/daemon.json <<-'EOF'
    {
    "registry-mirrors": ["https://xxxxx.mirror.aliyuncs.com"]
    }
    EOF
    sudo systemctl daemon-reload
    sudo systemctl restart docker

Pulling the Plex Image

Detailed instructions for using this image can be found here. I chose the one with the highest download count linuxserver/plex - Docker Hub and not plexinc/pms-docker because the official image does not have an ARM version.

1
docker pull linuxserver/plex

Starting the Plex Image

I used the following command, as for why an SSH port 1122 is added, it’s just for precaution (which turned out to be useful later).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
docker create \
--name=plex \
-e PUID=1000 \
-e PGID=1000 \
-p 32400:32400 \
-p 32400:32400/udp \
-p 32469:32469 \
-p 32469:32469/udp \
-p 1122:22/tcp \
-p 5355:5353/udp \
-p 1900:1900/udp \
-v /mnt/plex/config:/config \
-v /mnt/plex/tv:/transcode \
-v /mnt/movies:/data \
--restart unless-stopped \
linuxserver/plex

You can see that a Docker Plex has been successfully created.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
root@raspberrypi:~# docker create \
> --name=plex \
> -e PUID=1000 \
> -e PGID=1000 \
> -p 32400:32400 \
> -p 32400:32400/udp \
> -p 32469:32469 \
> -p 32469:32469/udp \
> -p 1122:22/tcp \
> -p 5355:5353/udp \
> -p 1900:1900/udp \
> -v /mnt/plex/config:/config \
> -v /mnt/plex/tv:/transcode \
> -v /mnt/movies:/data \
> --restart unless-stopped \
> linuxserver/plex
8a7741bfb60428bcc2a3caa66fafcae98d7596c579dcd65dc30b624efe3bede5

Then start it, here you don’t need to enter the complete hash value. If the hash starts with 8a and there is only one, you can directly use docker start 8a, docker start 8 will also work.

1
docker start 8a7741bfb60

Successful Start

Then you can see that the Docker has successfully started.

1
2
3
root@raspberrypi:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8a7741bfb604 linuxserver/plex "/init" 19 seconds ago Up 12 seconds 3005/tcp, 0.0.0.0:1900->1900/udp, 32410/udp, 0.0.0.0:32400->32400/tcp, 0.0.0.0:32400->32400/udp, 0.0.0.0:32469->32469/udp, 8324/tcp, 0.0.0.0:32469->32469/tcp, 32412-32414/udp, 0.0.0.0:1122->22/tcp, 0.0.0.0:5355->5353/udp plex

Configuring Plex

Accessing the Web Interface

At this point, the Raspberry Pi’s 32400 port is mapped to the Docker’s 32400 port, and the Plex web configuration address is:

1
http://树莓派IP:32400/web

After accessing it, you will see the following screen.

its-web

Register and Log In

After registering, your account should be automatically logged in.

Error: Server Not Found

Then, there is a problem… After some searching, it seems that for the initial configuration, you need to connect using 127.0.0.1, and then the configuration will be displayed. So I continued the configuration through an SSH tunnel.

error-found

Error: Use Xshell’s SSH Tunnel Function for Configuration

  1. First, connect to the Plex Docker and install OpenSSH and Vim.

    1
    docker exec -it 8a /bin/bash
  2. Use APT to install OpenSSH and Vim.

    1
    apt update && apt install openssh-server vim vim-common -y
  3. After the installation, edit /etc/ssh/sshd_config and change PermitRootLogin prohibit-password to PermitRootLogin yes.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    ......
    #LogLevel INFO

    # Authentication:

    #LoginGraceTime 2m
    # 修改这里
    # PermitRootLogin prohibit-password
    PermitRootLogin yes
    #StrictModes yes
    ........
  4. Change the root password and start the SSH service.

    1
    2
    passwd root
    service ssh start
  5. If you’re using Xshell, create a new connection. The address is the Raspberry Pi’s IP, and the port is 1122. Then choose Properties - SSH - Tunneling. add-ssh-tunnel

  6. Connect with this SSH connection.

Connecting to Docker Configuration

Discovering the Server

If you encounter the problem mentioned earlier, which is “No soup for you”, then you need to use an SSH tunnel and open the following address in your browser.

Open this address in your browser
1
2
3
http://127.0.0.1:32400/web

因为上面配了ssh隧道, 所以访问本机的32400端口的请求会全部通过树莓派1122端口(就是plex docker)并转发到localhost:32400的端口, 而plex会认为这个请求是localhost请求.
Then you will see this screen

find-server

Adding a Library

add-library

When creating, I added -v /mnt/movies:/data, so the Raspberry Pi’s /mnt/movies is mapped to the /data directory.

videos

Movie List

video-list

Codec Not Found

If you see the following message:

1
Conversion failed. A required codec could not be found or failed to install.

it means the codec download failed. The codecs are downloaded to this directory:

1
2
3
4
/config/Library/Application Support/Plex Media Server/Codecs

因为创建的时候设了 -v /mnt/plex/config:/config
所以也存在树莓派的/mnt/plex/config中

You can check the Plex logs to see which codec is being downloaded or you can try playing again, it will automatically download again, and eventually, it will succeed.

Log directory

1
/config/Library/Application Support/Plex Media Server/Logs/Plex Media Server.log

You can see which codec failed to download in the logs, the log structure is as follows:

1
2
3
4
5
6
......
Feb 08, 2020 13:13:27.728 [0xa77f2450] DEBUG - Downloading document http://127.0.0.1:32400/library/metadata/2?checkFiles=1&includeBandwidths=1&offset=-1&X-Plex-Incomplete-Segments=1&X-Plex-Session-Identifier=9y4kv4qpxsk5ajjc2xs8aznq
Feb 08, 2020 13:13:27.750 [0xa77f2450] DEBUG - HTTP requesting GET https://plex.tv/api/codecs/easyaudioencoder?build=linux-armv7hf_neon-standard&deviceId=d6abcef7-53e4-44a9-a050-c1ec7ce7dd5f&oldestPreviousVersion=1%2E18%2E4%2E2171-ac2afe5f8&version=436
Feb 08, 2020 13:13:30.262 [0xa77f2450] WARN - HTTP error requesting GET https://plex.tv/api/codecs/easyaudioencoder?build=linux-armv7hf_neon-standard&deviceId=d6abcef7-53e4-44a9-a050-c1ec7ce7dd5f&oldestPreviousVersion=1%2E18%2E4%2E2171-ac2afe5f8&version=436 (0, No error) (Could not resolve host: plex.tv)
-----这里可以看到下载失败了, 那就手动下载
.....

Brief Test (Raspberry Pi 4 CPU overclocked to 2.0G, Room Temperature 9°C)

Detective Conan: The Fist of Blue Sapphire H.264 1:49:27

Detective Conan: The Fist of Blue Sapphire BDMV Remux H.264, True HD Audio 18GB MKV

Original Quality (Unable to select subtitles) 42℃

TOP
1
2
PID   USER     PR  NI    VIRT    RES     SHR  S  %CPU  %MEM    TIME+    COMMAND
4418 pi 20 0 130724 69572 8632 R 53.5 1.7 0:15.99 Plex Transcoder
Random Clip Jump Time
  1. Click on the progress bar until the image appears: 6 seconds
  2. Image appears to jump to the corresponding timeline and play: 2 seconds
Playback Status

No buffering, but there is severe frame skipping while playing, about every 4 seconds, 1 second is skipped.

Transcoding to 1080p 61℃

TOP
1
2
PID   USER      PR  NI    VIRT    RES     SHR  S  %CPU  %MEM    TIME+    COMMAND
2843 pi 20 0 585476 339720 9856 R 288.7 8.5 5:22.03 Plex Transcoder
Random Clip Jump Time
  1. Click on the progress bar until the image appears: 25 seconds
  2. Image appears to jump to the corresponding timeline and play: 7 seconds
Playback Status

Buffering occurs, about 1 buffer every 20 seconds, buffering for 3 seconds, frequent buffering

Detective Conan Episode 993 The Conspiracy at the Food Court H.264 24:44

Detective Conan Episode 993 The Conspiracy at the Food Court H.264, AAC 227MB MP4

Original Quality 36℃

TOP
1
2
PID   USER      PR  NI    VIRT    RES     SHR  S  %CPU  %MEM    TIME+    COMMAND
1816 pi 20 0 407508 57204 29780 S 14.9 1.4 1:58.82 Plex Media Serv
Random Clip Jump Time
  1. Click on the progress bar until the image appears: less than 1 second, almost instant play
  2. Image appears to jump to the corresponding timeline and play: less than 1 second, almost instant play
Playback Status

No buffering or any issues within 1 minute, smooth playback

Transcoding to 328p 51℃

TOP
1
2
PID   USER      PR  NI    VIRT    RES     SHR  S  %CPU  %MEM    TIME+    COMMAND
8031 pi 20 0 305676 96348 9528 R 317.9 2.4 0:45.67 Plex Transcoder
Random Clip Jump Time
  1. Click on the progress bar until the image appears: 11 seconds
  2. Image appears to jump to the corresponding timeline and play: no image skipping during jump
Playback Status

No buffering or any issues within 1 minute, smooth playback

Detective Conan: The Zero Enforcer HEVC 1:51:20

Detective Conan: The Zero Enforcer BDRip H.265(HEVC), Flac 5.6GB MKV

Transcoding of Original Quality (Unable to select original output) 73℃

TOP
1
2
PID   USER     PR  NI    VIRT    RES     SHR  S  %CPU  %MEM    TIME+    COMMAND
10115 pi 20 0 626908 341284 9448 R 341.2 8.5 1:16.10 Plex Transcoder
Random Clip Jump Time
  1. Click on the progress bar until the image appears: 21 seconds
  2. Image appears to jump to the corresponding timeline and play: 10 seconds
Playback Status

No buffering, but there is severe frame skipping while playing, about every 10 seconds, 1 second is skipped.

Natsume’s Book of Friends Season 4 Episode 6 The Other Side of the Glass H.264 24:17

Natsume’s Book of Friends Season 4 Episode 6 The Other Side of the Glass H.264 10Bit AAC 160MB MKV

Transcoding of Original Quality (Unable to select original output) 71℃

TOP
1
2
PID   USER      PR  NI    VIRT    RES     SHR  S  %CPU  %MEM    TIME+    COMMAND
11568 pi 20 0 546356 332752 10668 S 375.5 8.3 0:25.80 Plex Transcoder
Random Clip Jump Time
  1. Click on the progress bar until the image appears: 14 seconds
  2. Image appears to jump to the corresponding timeline and play: 2 seconds
Playback Status

No buffering or any issues within 1 minute, smooth playback

Love, Death and Robot H.265 12:06

Love, Death and Robot H.265, Ec-3 650MB MP4

Transcoding of Original Quality (Unable to select original output) 76℃

TOP
1
2
PID   USER      PR  NI   VIRT    RES     SHR  S  %CPU  %MEM    TIME+    COMMAND
12998 pi 20 0 505908 266772 9036 S 352.9 6.7 0:51.67 Plex Transcoder
Random Clip Jump Time
  1. Click on the progress bar until the image appears: 32 seconds
  2. Image appears to jump to the corresponding timeline and play: 10 seconds
Playback Status

No buffering or any issues within 1 minute, smooth playback

Zootopia H.264 1:48:44

Zootopia BDRip H.264 DTS 16GB MKV

Transcoding of Original Quality (Unable to select original output) 73℃

TOP
1
2
PID   USER    PR  NI   VIRT    RES     SHR  S  %CPU   %MEM    TIME+    COMMAND
14271 pi 20 0 631596 392168 10296 R 393.8 9.8 0:17.84 Plex Transcoder
Random Clip Jump Time
  1. Click on the progress bar until the image appears: 26 seconds
  2. Image appears to jump to the corresponding timeline and play: 9 seconds
Playback Status

No buffering or any issues within 1 minute, smooth playback

Summary of Brief Test (Table)

Movie Title File Size Transcoding Codec Duration CPU Usage Temperature Smoothness
Detective Conan: The Fist of Blue Sapphire 17.61GB No H.264 1:49:27 53.5% 42℃ No buffering, severe frame skipping
Detective Conan: The Fist of Blue Sapphire 17.61GB Yes H.264 1:49:27 288.7% 61℃ Very choppy
Detective Conan: The Conspiracy at the Food Court 226.04MB No H.264 24:44 14.9% 36℃ Perfect
Detective Conan: The Conspiracy at the Food Court 226.04MB Yes H.264 24:44 317.9% 51℃ Perfect
Detective Conan: The Zero Enforcer 5.63GB Yes H.265 1:51:20 341.2% 73℃ No buffering, severe frame skipping
Natsume’s Book of Friends: The Other Side of the Glass 160.3GB Yes H.264 10Bit 24:17 375.5% 71℃ No buffering
Love, Death and Robot 656.66MB Yes H.265 12:06 352.9% 76℃ No buffering
Zootopia 13.89GB Yes H.264 1:48:44 393.8% 73℃ No buffering