Skip to content

Instantly share code, notes, and snippets.

@andreanidouglas
Created August 23, 2022 13:57
Show Gist options
  • Save andreanidouglas/1dc833c21db6200e0dbb7a11bb4b3710 to your computer and use it in GitHub Desktop.
Save andreanidouglas/1dc833c21db6200e0dbb7a11bb4b3710 to your computer and use it in GitHub Desktop.
Quick convert movies to x265
## This script is not totally error free. If your seas path has any spaces, it will shit itself out. Be careful
## Also, I usually run this on docker to avoid having to deal with ffmpeg dependencies on the host machine (linuxserver/ffmpeg)
#!/bin/sh
set -e
seas="/media/Videos" # place with videos
pushd "$seas"
files=$(find . -type f -name "*.mkv" | xargs -0)
for file in $files; do
date=$(date)
echo "$date" "|" Starting: "$file"
base=$(basename "$file" .mkv)
echo "$base"
## Run ffmpeg and remove any verbose output. If you have a NVDIA GPU, you can replace libx265 with hevc_nvenc for better performance
ffmpeg -nostats -hide_banner -loglevel error -y -i "$file" -c:v libx265 -crf 28 -preset fast -c:a copy /out/"$base"_x265.mkv
mv /out/"$base"_x265.mkv "$seas"
rm "$file"
echo "$date" "|" Ended: "$file"
echo ""
echo ""
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment