With Plex, understanding the difference between direct play, direct stream, and transcoding can make all the difference to the enjoyment of the movies that are streamed from your Plex server. Your Plex Media Server can play pretty much any media file format you can add to it, with the exception of image formats. When it comes to video files, there are certain aspects of how a media file is encoded that could impact how Plex sends the file to a client.
Every client that is supported by Plex may not be able to natively play a particular media file without some help from the Plex server. Understanding which media files won't play, and why they won't play on a particular client is important when managing a Plex server.
Let's look at how a media file (I am mainly talking about video files) is comprised and how Plex would deal with specific files when streaming to a client.
How a media file is structured
Each video file that is stored on your hard drive is not just a simple file with the video and audio joined together. All video files are comprised of four main parts:
- 1. Container: mp4, mkv, avi, etc.
- A container is basically that - it holds the video and audio stream, and any included subtitles. Depending on the container, it can hold multiple audio streams, such as one for stereo and one for surround sound.
- 2. Video codec: H.264/x264/avc, H.265/x265/HEVC, divx, etc.
- Each video stream is encoded using a specific video codec. There are many different codes in use, but the most popular and widely supported is the H.264 codec. The H.265 codec is a newer codec used for 4K videos, but many 1080p videos are also starting to be encoded with H.265 because of the smaller file size.
- 3. Audo codec: AAC, AC-3, DTS, MP3, etc.
- Similiar to the video stream, audio streams are also encoded using various codecs. Popular, and widely supported codecs in use today are AAC and AC-3. Some containers, such as mkv, can support multiple audio streams, and each stream can be encoded using a different codec.
- 4. Subtitles: SRT, VOBSUB, PGS, etc.
- The last part of a video container is the subtitles. These can include subtitles of real languages, or for languages used in fantasy movies. Some subtitles may even be burned into the video to avoid having to add the subtitles in later.
Each video file that you add to Plex will include the above parts in the video container. Understanding how your video file is encoded - which video and audio formats are used - will make managing your Plex server much easier.
Each client that you use to play a file has the ability to play specific formats of videos and audio codecs. A client may also only be able to process a video that is below a specific bitrate - usually measured in megabits per second (Mbps). Knowing what your client devices will support is key to ensure you get the best experience out of Plex.
There are three ways Plex will handle streaming media to a client device. The three ways are discussed below.
This is the ultimate way you want your Plex Media Server to handle a media file it is streaming to a client device. When Plex chooses to direct play a file, that means the media file is 100% compatible with the client device, and the Plex server needs to do nothing with the media file except send it to the client device.
Since Plex only sends the media file to the client as-is, this method uses almost no CPU on the server.
The next best thing to direct playing a media file is to direct stream it. Plex chooses to direct stream a file to a client when the client doesn't natively support the container of the media file, but both the video and audio formats are supported. For example, you media file is in an mkv container, but the client only supports mp4. Plex will remux the file by copying the video and audio streams into a client-compatible container.
Direct Stream requires very little CPU usage on your Plex Media Server.
What if your client doesn't support either the video or audio stream of your media file? Plex would need to convert the incompatible stream into a compatible format. Plex does this by transcoding the stream.
If Plex needs to transcode the video, then a lot of CPU will be needed, while transcoding audio will use a moderate amount of the CPU. If the machine you use isn't dedicated to Plex, then you can notice your system becoming slow when Plex is transcoding.
In addition, if your CPU isn't powerful enough to transcode video or audio on the fly, then you may notice significant buffering as the client device waits for Plex to transcode the stream and send it to the client.
Widely supported format
When managing your Plex server, you would probably want to direct play your media files as much as possible. Doing so will reduce CPU usage on your server, and allow you to stream more media.
In order to direct play as much as possible, and avoid transcoding, you would need to know the clients that are connect to your Plex server. It may be easy when only your devices are used to connect to your Plex server, but if you allow others outside your home to stream your media, then things get a bit more complicated.
A good starting point for encoding your media files is to use the following formats:
- Container: mp4
- Resolution: 1920x1080 or lower
- Video codec: H.264 (level 4.0 or lower)
- Framerate: 30 fps (bit depth: 8)
- Audio Codec: AAC (2 channels)
- Bitrate: 20 Mbps or lower
The above specs should allow you to direct play media within your network. For outside your network, you should reduce the bitrate to a lower value than the bandwidths limits of your server, or the upload speed of you Internet connection.