Sunday, June 4, 2017

SOLUTION: Plex Media Server Keeps Renaming Movie Files

I first discovered Plex Media Server when looking for a way to stream backed-up copies of my DVD collection from my Synology Disk Station Network Attached Storage (NAS) device. It seemed like the perfect solution: All I had to do was copy my properly named and organized movie files to the NAS and Plex would serve them up to the Roku devices in my home. Only something annoying kept happening to my uploaded movies as soon as the Plex Media Server added them to my Plex library: Instead of using the nicely-formatted, correct titles that I assigned each of my movie files before copying them to the NAS, Plex consistently replaced their entries in the library with ugly and sometimes meaningless titles instead. For example, Plex renamed "The Sinister Saga of Making the Stunt Man (2000)" to "SINISTER_SAGA.Title1" and renamed "Inspector Morse: Cherubim and Seraphim (1992)" to "DLT16013.Title2".

These changes were confounding, because I followed Plex's instructions for naming and organizing movie files, but the Plex Media Server was clearly ignoring my effort and replacing my tidy titles with... something else. In most cases, Plex's renaming behavior didn't just cause the titles to look ugly- it also interfered with Plex's ability to download relevant data for most of the films, particularly the movie poster box art.

In the below screenshot you can see that plex only identified one of my movie files correctly, while it renamed all of the others with the unexpected title names, and used generic thumbnails instead of downloading the movie posters.



Well it took me several days of research and experimentation (and scouring the Plex forums where some users' independent discoveries helped light the way), but I finally both figured out what was going on and came up with a way to fix it.

ROOT CAUSE

Plex uses a variety of different media detection and matching methods in order to correctly identify titles and download the appropriate metadata (plot summary, box art, etc.). In my case, Plex was doing two different things that were causing my correctly-named files to be renamed once they were processed in the Plex database: First, Plex was ignoring file and folder names in cases where it looked into an individual file's metadata and found a "Title" property in the metadata. Also, the agents Plex uses to identify movies were running in the wrong order for my library settings, so Plex wasn't performing the expected lookup operations in cases where it found the "Title" property in a file.

SOLUTION

I've come up with a workflow that guarantees that when Plex detects your media files it uses online information first, before attempting to look inside your files' metadata for an alternative title. There are three different aspects to this: Your Plex server settings, your Plex library settings, and your individual files- so I will address each of them separately.

Note: I encountered this problem (and fixed it) using Plex Media Server both on my Synology DS214se NAS and on a computer running Windows 7. My NAS has version 1.5.3 of Plex installed and my PC has a slightly newer version, 1.5.6. My steps work the same for both versions/platforms.

Plex Server Settings

You only have to make this change once per Plex server in your home. Ideally you should do this before creating any new Plex libraries, so that your libraries get scanned correctly the first time.

  1. Log in to your Plex server and click the Home icon to go to the Plex server's home page.
  2. Click the Settings icon in the top-right of the page and then click Server to view the Server settings.

    Note: If you get a "server settings are unavailable" message, it sometimes helps to sign out from your Plex account (the icon in the upper-right corner of the page) and then sign back in and try again.
     
  3. Once you're on the Server tab of the Settings page, click Agents and then click Movies.
  4. Below Movies, click Plex Movie. The sub-agents that the "Plex Movie" agent uses when matching media are listed below in order of precedence. The "Local Media Assets (Movies)" sub agent is the one that looks inside your files for the Title metadata tag. Select Local Meda Assets and drag it to the bottom of this list! Also, make sure that Plex Movie is at the top. The "Plex Movie" option cannot be unchecked, but you can optionally check/uncheck the other options in this list. Remember, Plex will use these agents in the order that they appear here.
    Correct sub-agent order for Plex Movie agent.
  5. Next, under Movies, select The Movie Database and make the same kind of adjustments: Drag Local Media Assets (Movies) to the bottom of the list and make sure The Movie Database is on the top. You can check/uncheck other sub-agent options if you wish.
    Correct sub-agent order for The Movie Database agent.
  6. Click the Home icon to return to the main Plex screen. Under Libraries on the left side of the page, click the ... icon next to your Movies library, then click Refresh All > Refresh. This rebuilds your library using your new server settings. Already you can see a huge improvement in my own library. Note that two titles still have mangled names- that's because neither of these films exists in the Plex Movie database, so Plex fell back on the Local Media Assets agent to extract their metadata. We'll tackle this problem in the "Preparing Your Files" section below.
    My library after changing the sub-agent order and performing a "Refresh All."

Plex Library Settings

In order for the Plex server settings we changed to have any effect we need to make sure our libraries have the correct agent settings for the desired media type. In the case of movie files, this means you should select either Plex Movie or The Movie Database.

Editing an existing library

  1. On the left side of the Plex server home page, click the ... next to your Movies library under Libraries, and then click Edit.
  2. On the Edit Library screen, click Advanced and then scroll down to where you can see the Scanner and Agent settings.
  3. For Scanner, select Plex Movie Scanner.
  4. For Agent, select either Plex Movie or The Movie Database. Each agent has some other customization options that appear below.
  5. When you have chosen your desired settings, click Save Changes.
  6. Back on the Plex server home page, under Libraries on the left side of the page, click the ... icon next to your Movies library, then click Refresh All > Refresh.

Creating a new library

  1. On the Plex server home page, click the + next to Libraries.
  2. On the Select type tab, click Movies and optionally name your library.
  3. On the Add folders tab, click Browse For Media Folder to locate and add folders that Plex will search when updating this library. You can add multiple folders to a single library.
  4. On the Advanced tab, scroll down until you can see the Scanner and Agent settings.
  5. For Scanner, select Plex Movie Scanner.
  6. For Agent, select either Plex Movie or The Movie Database, and check any of the additional options that appear below.
  7. Click Add Library to complete the process and begin scanning for media.

Preparing Your Files

  1. Before you even try to add any movie files to Plex, you should make sure you are following the recommended folder and file naming scheme. Plex's instructions are pretty clear, but it basically boils down to: Put each movie into its own folder, and name the folders and movie files in this format: "Movie Title (year).ext" (Where "ext" is the filename extension of the movie (mkv, mp4, m4v, etc.).
    Here you can see that each of my movie files is stored in its own folder, with both the folder and movie file following the same naming convention.
  2. Even after fixing my Plex server settings, some of my files were still getting renamed unexpectedly, and this was because the media files contained metadata tags that had those undesired names in the Title property. Notice the following:
    The title on the left (listed as DLT16013) is for a file in my library named "Inspector Morse - Cherubim and Seraphim (1992).m4v". If I locate that file in Windows File Explorer, right-click the file, and go to Properties > Details, this is what I see:
    The source of the problem.
    To fix this, click the link at the bottom of the Details page that says "Remove Properties and Personal Information". This opens a Remove Properties dialog where you can choose to either just remove individual properties by checking them or creating a new copy of the file with all possible properties removed. I like to choose this second option, and then delete the original file once I make sure that the new file is working properly.
    If you choose the "Create a copy" option the new file will have a modified filename. For example, when I removed the properties from a file named "Doomed Flight (1998).m4v" the resulting file was named "Doomed Flight (1998) - Copy.m4v." Plex appears to be smart enough to ignore the "- Copy" part of the filename when detecting media, but if you go this route you might choose to manually trim that text out of the filename before refreshing your library.
  3. If you had to remove metadata in order to fix a problem in an existing library you might have to do a "Refresh All" on the library to force Plex to re-inspect your modified files. I chose to make new copies of my problem files and uploaded them with different filenames (with the "- Copy" still there), and as a result I only had to do a "Update Library" in order to fix the handful of problem entries rather than rebuilding the whole database.
After performing all of the steps above I finally have a Movies library that lists all my movies the way I intended them to appear. The Doomed Flight and Inspector Morse movies still have generic thumbnails since they weren't in any of the movie databases, but at least their titles/years correctly appear in the library now:
Yes!

7 comments:

Unknown said...

Thank you soooo much for this! Man, do you happen to need to organize anything else? Your a genius at writing an easy to follow, step-by-step guide.

Thanks again...

Unknown said...

You absolutely nailed the fix for this naming issue Plex had for me. Thank you 1

Casp said...

Beautifully rendered post... Thank-you...

Glenn Sullivan said...

Thank you this solved my problem. Well documented

Damien said...

Thank you!!! You are our true HERO! This worked perfectly - especially creating another copy via "windows" side of the house, with "all possible file detail properties" removed! After that, I didn't have to 'refresh library metadata;' just "Scan Library Files" for the specific library and it's fixed!

Daniel said...

Worked perfect, thanks for that!

dbizzzz said...

Does anyone know how to force filename as sort order name ?