Request: automate reencoding

Hi,

Plex supports a wide variety of video formats, however, it can struggle to process some legacy formats.

It would help if the scheduler added support for automatically performing ffmpeg -i <input-file> -c:v libx264 -c:a aac <output-basename>.mp4 on legacy files, like AVI, MPEG, MPG, and WMV.

After reencoding, the original files enter a deletion confirmation pool. The Plex server Web UI could display a confirmation banner to remove these. With an option to hide the banner and preserve originals, for people who want that.

In order to respect computing resources, provide customizable thresholds for max CPU cap and minimum available disk space before pausing reencoding.

The destination directory for reencoded files should probably reside outside of any libraries. That way, we avoid duplicates. A banner prompt could permit the new files to move into the libraries.

Oh, and the new files should automatically receive the same Plex metadata as the originals.

I solved this problem a different way but very close to your proposal. I worked with AI (Copilot) to create a powershell script on Windows that will recurse all files and sub-folders from the location the script runs and search for files that require reencoding (using ffprobe), then it reencodes them using ffmpeg. The files are replaced with the new encoded file and the originals are stored in a separate folder in case they need to be restored. After reencoding, the library items do need to be rescanned (and possibly re-Analyzed) but overall I am realy happy with the results. My script actually uses hardware encoding based on the two computers I run this on. One can process at about 12x speed and the other 8x. The script can also be run on a specific subset of files using wildcards, etc. instead or running on everything within the starting folder. In my case, I encoded everything to HEVC to save space and HEVC seems to work well on all my clients. I also have a version of this script run after the Plex DVR completes a recording so the problem does not recur. Reencoding to HEVC basically shrank my media folders in half. I did need to use one of the latest ffmpeg builds as some of the ffmpeg options are not available in older builds. I’ve attached the script here, it must be renamed to have a .ps1 extension and of course editted to meet your environment if you find it may be useful. Edit: I just noticed that you are likely on linux. you could upload my script to AI and ask AI to use it as a base to make a linux friendly script based on your environmental needs.

Convert_Folder_HEVC.txt (4.6 KB)

If you want to mass-transcode-and-replace your media you can use tools like Tdarr for that. This isn’t really something the Plex server itself needs to be involved in. Not all client devices have issues with those formats to begin with, and Plex is made to transcode on-playback for devices that cannot handle a certain format, or cache such work as “optimized versions” while leaving the originals intact for other clients.