Difference between revisions of "Plex"

From ArchWiki
Jump to: navigation, search
(Plex Home Theater)
(Remote access through vpn: remove out of scope section)
 
(84 intermediate revisions by 29 users not shown)
Line 1: Line 1:
 
[[Category:Streaming]]
 
[[Category:Streaming]]
 +
[[ja:Plex]]
 +
[https://www.plex.tv/ Plex] is a media player system and software suite consisting of many player applications for 10-foot user interfaces and an associated media server that organizes personal media stored on local devices. Integrated Plex Channels provide users with access to a growing number of online content providers such as YouTube, Vimeo, TEDTalks, and CNN among others. Plex also provides integration for cloud services including Dropbox, Box, Google Drive, or Copy.
  
{{Merge|List of Applications|This article doesn't offer more information than an entry in [[List of Applications]], although I think we'd need to create a new section for this kind of applications.}}
+
Plex for Linux is split into a closed-source server Plex Media Server, and an open-source client Plex Home Theater, a fork of the popular [[Kodi]] project.
  
Landing page for http://plexapp.com/
+
== Plex Media Server (PMS) ==
Please contribute and update.
+
 
 +
=== Installation ===
 +
 
 +
Install the {{AUR|plex-media-server}} package, or the {{AUR|plex-media-server-plexpass}} package if you have a Plex Pass.
 +
 
 +
=== Setup ===
 +
 
 +
[[Enable]] and start {{ic|plexmediaserver.service}}.
 +
 
 +
To begin configuring PMS, browse to {{ic|http://localhost:32400/web/}}.
 +
 
 +
To configure PMS remotely, you must first create an SSH tunnel (setup can only be done from <code>localhost</code>)
 +
 
 +
<code>ssh ip.address.of.server -L 8888:localhost:32400</code>
 +
 
 +
and then browse to {{ic|http://localhost:8888/web/}}.
 +
 
 +
=== Plugins ===
 +
 
 +
PMS can be expanded with additional plugins. For example, PMS can be used as an IPTV client with the [https://github.com/Cigaras/IPTV.bundle IPTV plugin].
 +
 
 +
Plugins can be installed inside {{ic|$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR/Plex Media Server/Plug-ins}}.
 +
 
 +
=== Plex Live TV and DVR ===
 +
 
 +
Plex live TV requires a plexpass.
 +
 
 +
To enable live TV viewing and DVR support with plex, you must have one of the supported tuners listed on the [https://support.plex.tv/hc/en-us/articles/225877427-Supported-DVR-Tuners-and-Antennas support page] and {{AUR|plex-media-server-plexpass}} installed. PMS will automatically recognize any connected tuners.
 +
 
 +
The plex user needs to be part of the video group in order to access local tuners. This can be done by running {{ic|usermod -a -G video plex}}
 +
 
 +
=== Security ===
 +
 
 +
It is recommended to store your media files outside of your home directory, as making it accessible to PMS would mean lowering its security. Having a separate {{ic|/media}} or {{ic|/mnt/media}} partition is a good setup for use with PMS.
 +
 
 +
You can further increase security via systemd, by [[edit]]ing {{ic|plexmediaserver.service}} as follows:
 +
 
 +
{{hc|/etc/systemd/system/plexmediaserver.service.d/restrict.conf|2=
 +
[Service]
 +
ReadOnlyDirectories=/
 +
ReadWriteDirectories=/var/lib/plex /tmp}}
 +
 
 +
{{Note|Those mechanisms are currently limited, see [[DeveloperWiki:Security#ReadOnly/ReadWrite]]{{Broken section link}}. For instance, ReadOnlyDirectories do not apply to any submount, you have to list them as well.}}
  
== Packages available in AUR ==
+
=== Resource Management ===
  
* {{AUR|plexmediaserver}}
+
Originally, PMS used ulimit to limit its allocated resources, however this is not compatible with running as a regular user. Instead, you can now set a maximum amount of memory via, again, systemd. For example, you can add:
* {{AUR|plexmediaserver-plexpass}}
 
* {{AUR|plexhometheater-git}}
 
* {{AUR|plex-ffmpeg-git}}
 
  
== Plex Media Server (PMS) ==
+
MemoryLimit=4G
 +
 
 +
to the file mentioned above.
 +
 
 +
=== Network ===
 +
 
 +
{{Note|PMS supports both IPv4 and IPv6. This section only assumes the use of IPv4.}}
 +
 
 +
PMS and its DLNA server require several ports to be open:
 +
 
 +
*Plex Media Server: TCP 32400
 +
*Plex DLNA Server: TCP 32469, UDP 1900
 +
*Network Discovery: UDP 32410, 32412, 32413, 32414
 +
*Bonjour/Avahi Network Discovery (legacy): UDP 5353
 +
 
 +
A short example with iptables:
 +
 
 +
# iptables -A INPUT -p tcp -m multiport --dports 32400,32469 -j ACCEPT
 +
# iptables -A INPUT -p udp -m multiport --dports 1900,32410,32412,32413,32414 -j ACCEPT
 +
 
 +
===Library Updates===
 +
Plex Media Server has a setting "Update my library automatically" which can detect new media files as they're downloaded to your library. But as your library grows, these updates might stop working reliably. To fix, you need to increase the number of files non-root users are allowed to subscribe to via inotify. Create the file {{ic|/etc/sysctl.d/40-max-user-watches.conf}}
 +
 
 +
{{hc|/etc/sysctl.d/40-max-user-watches.conf|2=
 +
fs.inotify.max_user_watches=524288
 +
}}
 +
 
 +
and run {{ic|sudo sysctl --system}} to apply without rebooting. Now plex should see any new files.
 +
 
 +
=== Troubleshooting ===
 +
 
 +
{{Expansion|1=Look if journalctl can be made equivalent with {{ic|1=SYSTEMD_LOG_LEVEL=debug}}, currently appears unreliable, see [[User talk:Alucryd#Plex]]}}
 +
 
 +
Logs are located in:
 +
 
 +
$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR/Plex Media Server/Logs
 +
 
 +
In case there are no logs or they are not helpful, you might want to launch PMS manually to get some terminal output:
 +
 
 +
sudo -u plex /usr/bin/bash
 +
source /etc/conf.d/plexmediaserver
 +
export LD_LIBRARY_PATH=/opt/plexmediaserver
 +
/opt/plexmediaserver/Plex\ Media\ Server
 +
 
 +
== Plex Home Theater (PHT) ==
 +
 
 +
Previously known as Plex Media Center, Plex Home Theater is the software component used for a long time as the front-end media player for Plex's back-end server component Plex Media Server. This component came from a fork of XBMC Media Center software on May 21, 2008.
 +
 
 +
Official support for Plex Home Theater (from Plex, Inc.) has been discontinued in favour of Plex Media Player (based on MPV). However, Plex Home Theater has been forked and is still under active development by the Open Source community under the name [https://github.com/RasPlex/OpenPHT OpenPHT]
  
 
=== Installation ===
 
=== Installation ===
  
Install the package from [[AUR]]: {{AUR|plexmediaserver}}.
+
[[Install]] the {{AUR|openpht}} package.
 +
 
 +
Plex Home Theater can be launched by running {{ic|plexhometheater.sh}} from your terminal.
 +
 
 +
== Plex Media Player (PMP) ==
 +
 
 +
Plex Media Player is the current release of Plex's media client. It has officially replaced [[#Plex Home Theater .28PHT.29|#Plex Home Theater (PHT)]] (which is still receiving bug fixes) and builds upon previous functionality, such as using mpv. Plex has made PMP [https://www.plex.tv/blog/plex-media-player-now-ambidextrous-free-kodi-said/ available] to all users and it has also become compatible with Kodi. Keep in mind, PMP is not open-source (unlike PHT).
 +
 
 +
=== Installation ===
  
=== Operation ===
+
[[Install]] the {{AUR|plex-media-player}} package.
  
To start plex, run sudo systemctl start plexmediaserver. Use sudo systemctl enable plexmediaserver to have it start on startup. Then go to localhost:32400/manage to set up plex. If you want to add media folders in your home directory you may get a permissions issue. chmod 775 ~/ and usermod -a -G users plex to allow plex to access your files.
+
== Kodi and PleXBMC ==
  
== Plex Home Theater ==
+
With the PleXBMC add-on, Kodi can be used as a replacement for PHT.
  
 
=== Installation ===
 
=== Installation ===
  
It is highly recommended to install using a clean chroot (https://wiki.archlinux.org/index.php/DeveloperWiki:Building_in_a_Clean_Chroot).
+
Install the {{Pkg|kodi}} package, then follow the instructions over [http://kodi.wiki/view/Add-on:PleXBMC here].
Install the package from [[AUR]]: {{AUR|plexhometheater-git}}. If GNOME is installed, the dependent package bluez will conflict with GNOME's dependency of bluez4; in this case edit the PKGBUILD to depend on bluez4 instead of bluez.
 

Latest revision as of 10:31, 5 November 2017

Plex is a media player system and software suite consisting of many player applications for 10-foot user interfaces and an associated media server that organizes personal media stored on local devices. Integrated Plex Channels provide users with access to a growing number of online content providers such as YouTube, Vimeo, TEDTalks, and CNN among others. Plex also provides integration for cloud services including Dropbox, Box, Google Drive, or Copy.

Plex for Linux is split into a closed-source server Plex Media Server, and an open-source client Plex Home Theater, a fork of the popular Kodi project.

Plex Media Server (PMS)

Installation

Install the plex-media-serverAUR package, or the plex-media-server-plexpassAUR package if you have a Plex Pass.

Setup

Enable and start plexmediaserver.service.

To begin configuring PMS, browse to http://localhost:32400/web/.

To configure PMS remotely, you must first create an SSH tunnel (setup can only be done from localhost)

ssh ip.address.of.server -L 8888:localhost:32400

and then browse to http://localhost:8888/web/.

Plugins

PMS can be expanded with additional plugins. For example, PMS can be used as an IPTV client with the IPTV plugin.

Plugins can be installed inside $PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR/Plex Media Server/Plug-ins.

Plex Live TV and DVR

Plex live TV requires a plexpass.

To enable live TV viewing and DVR support with plex, you must have one of the supported tuners listed on the support page and plex-media-server-plexpassAUR installed. PMS will automatically recognize any connected tuners.

The plex user needs to be part of the video group in order to access local tuners. This can be done by running usermod -a -G video plex

Security

It is recommended to store your media files outside of your home directory, as making it accessible to PMS would mean lowering its security. Having a separate /media or /mnt/media partition is a good setup for use with PMS.

You can further increase security via systemd, by editing plexmediaserver.service as follows:

/etc/systemd/system/plexmediaserver.service.d/restrict.conf
[Service]
ReadOnlyDirectories=/
ReadWriteDirectories=/var/lib/plex /tmp
Note: Those mechanisms are currently limited, see DeveloperWiki:Security#ReadOnly/ReadWrite[broken link: invalid section]. For instance, ReadOnlyDirectories do not apply to any submount, you have to list them as well.

Resource Management

Originally, PMS used ulimit to limit its allocated resources, however this is not compatible with running as a regular user. Instead, you can now set a maximum amount of memory via, again, systemd. For example, you can add:

MemoryLimit=4G

to the file mentioned above.

Network

Note: PMS supports both IPv4 and IPv6. This section only assumes the use of IPv4.

PMS and its DLNA server require several ports to be open:

  • Plex Media Server: TCP 32400
  • Plex DLNA Server: TCP 32469, UDP 1900
  • Network Discovery: UDP 32410, 32412, 32413, 32414
  • Bonjour/Avahi Network Discovery (legacy): UDP 5353

A short example with iptables:

# iptables -A INPUT -p tcp -m multiport --dports 32400,32469 -j ACCEPT
# iptables -A INPUT -p udp -m multiport --dports 1900,32410,32412,32413,32414 -j ACCEPT

Library Updates

Plex Media Server has a setting "Update my library automatically" which can detect new media files as they're downloaded to your library. But as your library grows, these updates might stop working reliably. To fix, you need to increase the number of files non-root users are allowed to subscribe to via inotify. Create the file /etc/sysctl.d/40-max-user-watches.conf

/etc/sysctl.d/40-max-user-watches.conf
fs.inotify.max_user_watches=524288

and run sudo sysctl --system to apply without rebooting. Now plex should see any new files.

Troubleshooting

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: Look if journalctl can be made equivalent with SYSTEMD_LOG_LEVEL=debug, currently appears unreliable, see User talk:Alucryd#Plex (Discuss in Talk:Plex#)

Logs are located in:

$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR/Plex Media Server/Logs

In case there are no logs or they are not helpful, you might want to launch PMS manually to get some terminal output:

sudo -u plex /usr/bin/bash
source /etc/conf.d/plexmediaserver
export LD_LIBRARY_PATH=/opt/plexmediaserver
/opt/plexmediaserver/Plex\ Media\ Server

Plex Home Theater (PHT)

Previously known as Plex Media Center, Plex Home Theater is the software component used for a long time as the front-end media player for Plex's back-end server component Plex Media Server. This component came from a fork of XBMC Media Center software on May 21, 2008.

Official support for Plex Home Theater (from Plex, Inc.) has been discontinued in favour of Plex Media Player (based on MPV). However, Plex Home Theater has been forked and is still under active development by the Open Source community under the name OpenPHT

Installation

Install the openphtAUR package.

Plex Home Theater can be launched by running plexhometheater.sh from your terminal.

Plex Media Player (PMP)

Plex Media Player is the current release of Plex's media client. It has officially replaced #Plex Home Theater (PHT) (which is still receiving bug fixes) and builds upon previous functionality, such as using mpv. Plex has made PMP available to all users and it has also become compatible with Kodi. Keep in mind, PMP is not open-source (unlike PHT).

Installation

Install the plex-media-playerAUR package.

Kodi and PleXBMC

With the PleXBMC add-on, Kodi can be used as a replacement for PHT.

Installation

Install the kodi package, then follow the instructions over here.