Skip to content

Instantly share code, notes, and snippets.

@mikemcbride
Last active June 25, 2025 05:22
Show Gist options
  • Save mikemcbride/535e0da688bc8ebaab34af3a1e507ea6 to your computer and use it in GitHub Desktop.
Save mikemcbride/535e0da688bc8ebaab34af3a1e507ea6 to your computer and use it in GitHub Desktop.
Compress Video Files
# This script will loop through all files in the current directory and its subdirectories,
# and then will use ffmpeg to compress them using the H.265 codec.
# It will output the compressed files to a new directory called "optimized".
# This will retain the original directory structure, which is ideal for modifying video libraries like Plex.
for f in **/*;
if test -d $f;
mkdir -p optimized/$f;
else if test -f $f;
ffmpeg -i $f -vcodec libx265 -c:a copy -crf 28 -tag:v hvc1 optimized/$f;
end;
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment