Are you tired of wasting all your precocious NAS space to old video codecs? Well here’s some helpful tips to get them encoded to a more modern codec saving you potentially 80% of the disc space without any noticeable quality degradations.
We’ll use Either Handbrake or ffmpeg, both will work but ffmpeg has noticeably smaller files even when converting both to h265.
Here’s the core of the convert scripts:
#!/bin/bash
SRC=`dirname "$1"`
DEST_EXT="ffmpg.mkv"
RENAME="_CHECKME"
BACKUP="/var/backup"
strstr() {
[ "${1#*$2*}" = "$1" ] && return 1
return 0
}
die() {
echo "$1 - not converting";
exit
}
echo -n "Starting $1 - "
strstr "$1" $RENAME && die "$RENAME is in name"
strstr "$1" ffmpg && die "ffmpg is in name"
codec=`mediainfo --Inform="Video;%CodecID%" "$1"`
strstr $codec HEVC && die "HVEC already"
filename=$(basename "$1")
extension=${filename##*.}
filename=${filename%.*}
if ffmpeg -i "$1" -c:v libx265 -vtag hvc1 "$SRC/$filename.$DEST_EXT"; then
if true; then
echo "DONE for $1";
mv -v "$1" $BACKUP/"$filename".$RENAME
else
echo "FAILED for $1" ;
fi;