Last active
December 5, 2023 18:20
-
-
Save dmacsuibhne/d5a99788e4330b0a2aa83b9d57ce8681 to your computer and use it in GitHub Desktop.
Compress videos with ffmpeg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
encoder=libx265 | |
crf_value=35 | |
preset_value="medium" | |
directory_original=./keep | |
directory_new="$directory_original/conv$crf_value$preset_value" | |
for filepath in ${directory_original}/*; do | |
if [ ! -d "$filepath" ]; then #exclude directories | |
filename_with_extension="${filepath##*/}" | |
filename_no_extension="${filename_with_extension%.*}" | |
new_path="$directory_new/${filename_no_extension}_${encoder}_crf${crf_value}_${preset_value}.mp4" | |
( # Subshell so set -x only prints inside of loop | |
set -x | |
ffmpeg -i "$filepath" -c:v ${encoder} -crf ${crf_value} -preset ${preset_value} -vtag hvc1 $new_path | |
) | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment