I'm creating a script to convert my movie and TV show library on my NAS to meet specific criteria: 1280x720 resolution using HEVC or x265 codec. I'm currently handling the resolution scaling part, but I'm a bit stuck on how to check for the codec. I want to process videos that aren't already 1280x720 and not using HEVC/x265; otherwise, I want to skip them. Any guidance on how to implement this would be appreciated!
3 Answers
There's actually a tool called Tdarr that can automate this process for you. It compares file sizes before conversion to ensure that the transition to HEVC is efficient. It can also help with managing audio tracks and subtitles. But hey, where's the fun in not scripting everything yourself? I'm all about writing and tinkering too!
Are you looking to scale videos up, down, or both? It seems like you might be processing videos twice if they're already 1280x720. Before running your script on your entire library, consider testing it on a few sample files—especially those that are just above, just below, or already fit the specs. Here’s a structure you can follow to check the resolution and codec effectively: 1. Use ffprobe to fetch video details, including width, height, and codec. 2. Set conditions to see if it matches your target. 3. Only process videos that don't match.
If your goal is solely to scale down, make sure you check if the video exceeds either dimension before processing. You want to avoid duplicating efforts by upscaling videos that are already compliant.
I ran a script to find files in my library that aren’t compliant—either their resolution exceeds 1280x720 or they’re not encoded in HEVC. I found a total of 606 videos needing conversion. My plan is to downscale any that exceed resolution, keeping audio as is, and re-encode them to HEVC, appending .x256 to the file names after conversion. I'm mainly watching older shows and films, and honestly, I don’t mind the lower resolution as long as the quality holds up.

I'll definitely check out Tdarr, but I enjoy the process of creating my scripts. It’s satisfying to debug and improve upon them. Just upgraded my setup too, so I'm ready for more coding challenges!