I used to have a problem buying DVDs. If I saw one that was under $10.00 that I liked (or sort of liked, or had heard of, or thought looked cool) I’d buy it. Too cheap not to buy! My taste in movies is questionable (I’m ok with this) so I’ve amassed a decent collection of 80s action movies mixed with sci-fi, fantasy, and eclectic indie films (like Bubba Hotep).
As a card carrying member of the Computer Nerd Association of America I couldn’t
in good faith leave those DVDs on their discs without at least ripping them, so
that’s what I did. I didn’t do anything other than rip them, and I’d used
various tools over the years to do this so I currently have a folder with .mkv
files, and several with VIDEO_TS folders that seem to be a full backup of the
DVDs. I didn’t do any compression at the time, so most of these folders are
sitting around 6GB each on my JankyNAS.
For some reason (I was likely procrastinating something else I should have been doing), last week I decided to re-encode these and convert them all to mkv files in order to clean up some wasted space and make these easier to move around. I do have a Jellyfin install sitting around to stream media, but I don’t ever use it. Maybe some day.
In any case, the main point of this article is how to take a bunch of folders
with VIDEO_TS files in them and convert those into nice, self contained .mkv
files.
I installed handbrake on my OpenBSD home server (an old Intel
NUC). There was a package for it, so
installation was just doas pkg_add handbrake.
That machine is currently hosting grafana, unifi network application, a minecraft instance for my kids, and a photon install for reverse geocoding Dawarich points. It wasn’t really working too hard at all that so I figured it would be a good place to fire and forget multiple hours long encoding jobs. As a benefit it was already connected to my NAS via NFS so I didn’t need to copy files anywhere.
I ran the following command on Ghost Dog - The Way of the Samurai to see how the re-encode would turn out:
HandBrakeCLI \
-i "Ghost Dog The Way of the Samurai (1999)/VIDEO_TS" \
-o "Ghost Dog The Way of the Samurai (1999).mkv" \
--main-feature \
-e x264 -q 18 \
--aencoder copyAfter waiting for around 5 hours (I have old computers), the processing had
completed and I had a file that went from 5.6GB to 1.6GB, not bad in terms of
file storage cleanup when you consider there are probably around 50 of these
folders sitting around taking up space (56, just counted). I asked Gemini for
advice and Gemini suggested that I also use the
--encoder-preset fast flag which should speed up my encoding time without a
noticeable drop in visual quality (in theory).
I watched the re-encoded DVD and it looked great (I mean, as great as a plain old DVD can look on a 4k monitor) so I dumped the Handbrake command into a loop and am now waiting patiently for the remaining 55 films to complete.
Once this is done, I’ll double check that they are all working properly in Jellyfin and call it a day.
For reference, here’s the loop I’m using in the folder where all my ripped DVDs live:
#!/bin/sh
for d in */; do
if [ -d "$d/VIDEO_TS" ]; then
title="${d%/}"
if [ -f "$title.mkv" ]; then
echo "Skipping $title — $title.mkv already exists."
continue
fi
echo "=================================================="
echo "Processing: $title"
echo "=================================================="
HandBrakeCLI \
-i "$d/VIDEO_TS" \
-o "$title.mkv" \
--main-feature \
-e x264 -q 18 --encoder-preset fast \
--aencoder copy
fi
doneGemini also suggests I try the --decomb flag since my source material is DVD.
I’ll wait and see how these encodes turn out, and if I see any noticeable
artifacts, I’ll give that a try. So far, I haven’t noticed anything out of the
ordinary on Ghost
Dog or
Biutiful.