Merge b2de469c0ed8f5554f66b51506fc153762a2b09c into 475e4abb4084008198f1d9a23de6450e02b074a9

This commit is contained in:
TheYellowArchitect 2024-06-09 01:32:50 +00:00 committed by GitHub
commit 156bff319b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -91,6 +91,52 @@ cmd delete ${{
[ $ans = "y" ] && rm -rf -- $fx
}}
cmd compressvideo ${{
clear;
set -f;
converted_filenames=""; #notify-send variable
converted_files_count=0; #notify-send variable
echo "Compression Rate? (default: 31, maximum: 50)";
read -N 2 compressionRate;
#If not a number (e.g. empty), give default 31 value
if ! [[ $compressionRate =~ ^[0-5][0-9]$ ]]; then
compressionRate="31";
fi
for pickedFilepath in $fx; do
#could instead use ffprobe but would get more complicated as the filetype suffix becomes unknown
case $pickedFilepath in
*.mp4)
tempFilepath=$(echo "$pickedFilepath" | sed 's|.mp4|(CONVERTING).mp4|');
mv -f "$pickedFilepath" "$tempFilepath";
ffmpeg -i "$tempFilepath" -vcodec libx265 -crf "$compressionRate" "$pickedFilepath";
rm -f -- "$tempFilepath";
;;
*.webm | *.mkv)
newFilepath=$(echo "$pickedFilepath" | sed 's/\(.webm\|.mkv\)/.mp4/');
ffmpeg -i "$pickedFilepath" -vcodec libx265 -crf "$compressionRate" "$newFilepath";
rm -f -- "$pickedFilepath";
;;
*)
continue 1;;
esac
((converted_files_count=converted_files_count+1));
converted_filenames="$converted_filenames"$'\n'"$pickedFilepath";
done
#Notify the user of the results
if [[ $converted_files_count -gt 0 ]]; then
converted_filenames=$(echo "$converted_filenames" | sed 's|.*\/||');
notify-send "Compressed Videos($converted_files_count):" "$converted_filenames";
fi;
}}
cmd moveto ${{
clear; tput cup $(($(tput lines)/3)); tput bold
set -f
@ -177,5 +223,7 @@ map <c-l> unselect
map <a-x> compressvideo
# Source Bookmarks
source "~/.config/lf/shortcutrc"