From 5910987781f97caa1197264584b9c27580f5d251 Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Wed, 1 Mar 2023 01:14:23 +0300 Subject: [PATCH] Fix cache helper script --- cache_helper.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cache_helper.sh b/cache_helper.sh index c6b3d25..e96f9f7 100755 --- a/cache_helper.sh +++ b/cache_helper.sh @@ -8,20 +8,22 @@ fi total_before=0 total_after=0 for i in "$1"/*/*; do - if [ $(ffprobe -hide_banner -print_format json -select_streams a:0 -show_streams "$i" | jq '.streams[0].codec_name') != "vorbis" ]; then + if [ $(ffprobe -hide_banner -print_format json -select_streams a:0 -show_streams "$i" | jq -r '.streams[0].bit_rate') -gt 128000 ]; then size_before=$(stat --format=%s "$i") total_before=$(( $total_before + $size_before )) ffmpeg -hide_banner -loglevel error -i "$i" -vn "$i".ogg if [ $? -eq 0 ]; then size_after=$(stat --format=%s "$i".ogg) total_after=$(( $total_after + $size_after )) - echo "before: $(echo $size_before | numfmt --to=iec) | after: $(echo $size_after | numfmt --to=iec)" + + size_reduced=$(( $size_before - $size_after )) + echo "Reduced: $(echo $size_reduced | numfmt --to=iec)" mv "$i".ogg "$i" else echo "$i convert failed" fi else - echo "$i already compressed good" + echo "$i already OK" fi done