Re-optmizing videos after the original was replaced with a better quality

I have my server optimize all my movies for the purpose of streaming to low end hardware, as well as to make a backup of my main server files.

I notice, however, that if a movie or tv show is replaced with a better version (i.e. a 1080 replaces a 720), it doesn’t re-optimize the new video and because the original video was deleted, it deletes the optimized version it had as well. Is there something I can do to get it to rescan for the new file?

1 Like

Hoe did you optimize the file in the first place. Media optimize is a one-time action. If you used a filter to generate the list of items to optimize, then you’ll need to trigger that filter for the replacement.

Selected my movies library and clicked optimize. It optimizes any truly new items that come in, but none of the replacement items.

There were other threads about this that are now locked, but never resolved.

I’m not aware of these previous threads. I can’t think of why a replaced movie wouldn’t get optimized. The only reasons are if the file already meets the optimize criteria so it won’t create a duplicate. PMS still thinks the previous optimized file exists, but you said it was deleted so I don’t think this is the case.

If you can kick off another optimize job and then send me the PMS logs, I can check to see if there is any info on why it is skipping something. Let me know what movie it skipped.

Here’s one of the other threads I found:

If I hit the retry icon next to the deleted file it optimizes the new file, but with 2000 movies and 20000 TV shows, it can be cumbersome to scan through that list and manually hit the retry. Is there a commandline that would do this for me that I could run thru cron daily?

Can confirm, I still have this issue. I gave up on getting this fixed.

I’m confused. What icon are you referring to?

Here is an example. This file was replaced on my filesystem (such as a 720p file being deleted and a 1080p file being added). Plex automatically realized this and remapped the episode to the new file and removed the unavailable file link. The optimized version remains in a deleted state as shown.

image

If we manually press the retry icon there plex will reoptimize with the now replaced file.

What we would prefer and expect to happen is that when the plex library scanner sees that a file has been replaced and updates accordingly it would send a trigger to have the optimizer to run again on that file. Alternatively when the optimizer sees a source file is deleted it could check if another file exists for the same episode and re-optimize based on that file.

Does that make sense?

1 Like

MovieFan.Plex Do you need any further clarification? Are you able to look into having this issue addressed?

I don’t need anymore information. I’m testing a few things and will let you know if I need anything.

Awsome! Thanks for taking the time to look into it.

Yes, thank you MovieFan. This is the last piece I need for my Plex puzzle :slight_smile:

So any idea what’s happening with this?

Good timing. So here is what I found.

After creating an optimzied file. If you delete that optimized file manually, PMS does realize it’s gone but does not remove the entry from the Optimized Versions page. As long as it’s there, PMS will not create another new optimized files. The fix I found was to 1 - scan your library again. This should detect the missing file. 2 - empty trash. This will remove the entry from the Optimized Versions page. You should now be able to re-optimize these files using whatever procedures you did before.

So I think I understand what you are saying but in my setup the file will never be removed from the library. It’s on the same scan that it detects both the 720p file deletion and the 1080p file being added. If the process happened in the way you describe it would also bring the file back to the top of recently added.

I feel like if a source file of an optimized version is detected as deleted plex should then remove the optimized version (which it does currently) then plex should also mark the file as if it has never been optimized before and move it to the bottom of the queue to be optimized again. I get the rizk of sending it into an infinite loop so maybe make this an advance option.

Also for clarification, my optimizer usage is running an optimization of the 20 most recently aired episodes of TV. So quite often it will not work because 720p files almost always get replaced with 1080p and get stuck in the deleted state.

Yes, that’s what I am saying. You need to do those 2 steps I mentioned to trigger this. This is similar to the way Plex identifies if an original file is missing (not replaced by another, just gone). It has to scan the folder to see the file is missing to mark it for deletion from the database, then the empty trash which actually removes the entry from the database.

My library is setup to scan automatically and empty trash on every scan. Here are my settings:


So my library will see the new file and pick it up, add metadata and empty the trash to get rid of the deleted entry. The optimizer still gets stuck with the file in a deleted state because the database entry still exists but is now linked to a new file.

What will the optimizer do if it detects a file is replaced by another? That is the issue I am having.

Thanks for looking in on this. I tried your steps, but it doesn’t fix my particular problem either. Just to be clear, the optimized file is not the one being deleted manually. It is the original file that is deleted and then being replaced with a better quality. Once that original is replaced, plex is deleting the old optimized file and not queuing the system to re-optimize the new version of the original file.

Ok I’m seeing a slightly different behavior if I enable the option to scan the library automatically. With that enabled, I do not see the Plex Version getting deleted, so I have to manually remove it myself. Once I remove it, wait a little bit and the conversion starts again.

Steps

  • have a movie
  • optimize the movie
  • delete movie from file explorer
  • add replacement movie file with file epxlorer
  • PMS automatically scans this replacement
  • 2 counter over movie does not change since optimized version was not removed
  • remove Plex Version folder with file explorer
  • PMS starts the optimize process on the replacement file

Except for the part about having to delete the optimized version manually, I get the same results.

What platform are you testing on? I have a hunch that is why we are getting different results. Maybe it has something to do with the backend filesystem or something similar

I’m running Docker on unRAID. These are the steps for me.

  • have a movie
  • optimize the movie
  • delete movie from file explorer
  • add replacement movie file with file explorer
  • PMS automatically scans this replacement
  • 2 counter over movie is gone
  • optimized version is gone
  • PMS does not start the optimize process on the replacement file
  • movie shows as deleted in the optimizer list and conversion never starts (even after days and several library scans)
    *library shows one copy of the movie and no deleted files in Get Info

Ill throw up a WIndows server and run some tests.