From 1474e23aeae8030ddd051976757d525bbd2d1d46 Mon Sep 17 00:00:00 2001 From: Michael Campagnaro Date: Fri, 9 Jan 2026 12:09:56 -0500 Subject: [PATCH] Small tweaks --- .aliases | 18 +++++++++++------- ...restore-status => aws-check-restore-status} | 4 ++-- dotfiles/bin/aws-restore-deep-glacier-folder | 4 ++-- dotfiles/bin/compress-video | 12 ++++++++---- dotfiles/bin/compress-video-with-crf | 2 ++ dotfiles/bin/join-video | 6 +++--- dotfiles/bin/trim-video-target-rate | 2 +- dotfiles/bin/trim-video-vbr | 6 ++++-- 8 files changed, 33 insertions(+), 21 deletions(-) rename dotfiles/bin/{aws-see-restore-status => aws-check-restore-status} (93%) diff --git a/.aliases b/.aliases index 7700f29..776a5ae 100644 --- a/.aliases +++ b/.aliases @@ -230,13 +230,15 @@ if [[ "${platform,,}" == *'ming'* ]]; then _checksum() { local algo="$1" local file="$2" - certutil -hashfile $file $algo + certutil -hashfile "$file" $algo } alias checksum='certutil -hashfile' - alias checksum-md5='_checksum MD5' - alias checksum-sha1='_checksum SHA1' - alias checksum-sha256='_checksum SHA256' - alias checksum-sha512='_checksum SHA512' + + # I use delegating to certutil via _checksum() but these programs are faster. + alias checksum-md5='md5sum.exe' + alias checksum-sha1='sha1sum.exe' + alias checksum-sha256='sha256sum.exe' + alias checksum-sha512='sha512sum.exe' fi check_signature() { @@ -1285,11 +1287,13 @@ alias tv='echo can just do a cv with a time range...' #trim-video-vbr' function compress_and_normalize_volume() { local final_name="$1" + shift 1 + local opts="$@" if [[ $final_name == "" ]]; then - error "Provide a final file name" + error "Provide a final file name and optional args for compress-video" return fi - compress-video f.mp4 ff ; normalize-volume ff.mp4 "$final_name" + compress-video f.mp4 ff $opts ; normalize-volume ff.mp4 "$final_name" } alias cvn='compress_and_normalize_volume' diff --git a/dotfiles/bin/aws-see-restore-status b/dotfiles/bin/aws-check-restore-status similarity index 93% rename from dotfiles/bin/aws-see-restore-status rename to dotfiles/bin/aws-check-restore-status index 5059c33..9cb62af 100644 --- a/dotfiles/bin/aws-see-restore-status +++ b/dotfiles/bin/aws-check-restore-status @@ -2,7 +2,7 @@ # Shows you the status of an object restore job. # -# e.g. aws-see-restore-status my-deep-glacier-bucket object/path.png +# e.g. aws-check-restore-status my-deep-glacier-bucket object/path.png # # You know it's ready when ongoing-request is false and there's a date. If that field is null then the file isn't being restored. # @@ -65,7 +65,7 @@ bucket="$1" path="$2" if [[ $bucket == "" || $path == "" ]]; then - error "Usage: aws-see-restore-status " + error "Usage: aws-check-restore-status " exit 1 fi diff --git a/dotfiles/bin/aws-restore-deep-glacier-folder b/dotfiles/bin/aws-restore-deep-glacier-folder index 8668ad5..a852cf7 100644 --- a/dotfiles/bin/aws-restore-deep-glacier-folder +++ b/dotfiles/bin/aws-restore-deep-glacier-folder @@ -32,7 +32,7 @@ # # (obviously change the bucket and path to suit your needs). # -# Or use the aws-see-restore-status script. +# Or use the aws-check-restore-status script. # You know it's ready when ongoing-request is false and there's a date. If that # field is null then the file isn't being restored. # @@ -312,7 +312,7 @@ else fi printf "(Note: the time it takes to restore an object can be found in the AWS docs - just look for the $restore_tier restore tier, which is what you used.\\\nOnce restored, download the files from the S3 site or better yet use RCloneBrowser.\\\n" -printf "You can check the status of a file using the aws-see-restore-status script)\\\n" +printf "You can check the status of a file using the aws-check-restore-status script)\\\n" exec 3>&- diff --git a/dotfiles/bin/compress-video b/dotfiles/bin/compress-video index 0fdc58e..e5ca7dc 100644 --- a/dotfiles/bin/compress-video +++ b/dotfiles/bin/compress-video @@ -1,5 +1,7 @@ #!/usr/bin/env bash +# Bigger crf values == bigger compression. + if which tput >/dev/null 2>&1; then ncolors=$(tput colors) fi @@ -24,9 +26,12 @@ else fi use_gpu=1 +# Found the following to work best with vids containing text (e.g. programming vids). These give similar bitrates. +cpu_crf=20 +gpu_crf=33 if [[ $# < 2 || $# > 5 ]]; then - printf "${BOLD}${RED}Usage: compress-video ${NORMAL}\n" + printf "${BOLD}${RED}Usage: compress-video (NOTE: gpu crf is $gpu_crf and cpu crf is $cpu_crf - change it by calling compress-video-with-crf)${NORMAL}\n" exit 1 fi @@ -37,10 +42,9 @@ if [[ $# > 2 ]]; then use_gpu=$3 fi -# Found the following to work best with vids containing text (e.g. programming vid): 21 for CPU encoding and 28 for GPU (similar bitrates). -use_crf=21 +use_crf=$cpu_crf if [[ $use_gpu -eq 1 ]]; then - use_crf=33 + use_crf=$gpu_crf fi compress-video-with-crf $use_crf "$filename" "$output_name" $use_gpu $4 $5 diff --git a/dotfiles/bin/compress-video-with-crf b/dotfiles/bin/compress-video-with-crf index d538c0a..61958ec 100644 --- a/dotfiles/bin/compress-video-with-crf +++ b/dotfiles/bin/compress-video-with-crf @@ -1,5 +1,7 @@ #!/usr/bin/env bash +# Bigger crf values == bigger compression. + if which tput >/dev/null 2>&1; then ncolors=$(tput colors) fi diff --git a/dotfiles/bin/join-video b/dotfiles/bin/join-video index 0986ebd..0b74ae4 100644 --- a/dotfiles/bin/join-video +++ b/dotfiles/bin/join-video @@ -31,17 +31,17 @@ output="$2" target_crf="$3" max_bitrate_mb="$4" -default_crf="20" +default_crf="33" # if you want to compress then use the same gpu compression level from compress-video (i.e. 33, but verify it's still set to this) default_max_bitrate="6" if [[ $filename == "" || $output == "" ]]; then - printf "${BOLD}${RED}Usage: create a text file that lists the input video paths on separate lines using the format: file '/path/to/video'. Then call:\n\njoin-video <${NORMAL}\n" + printf "${BOLD}${RED}Usage: create a text file that lists the input video paths on separate lines using the format: file '/path/to/video'. Then call:\n\njoin-video ${NORMAL}\n" exit 1 fi extension="${output##*.}" if [[ $extension == $output ]]; then - printf "${BOLD}${RED}output arg should have an extension!\n\nUsage: join-video <${NORMAL}\n" + printf "${BOLD}${RED}output arg should have an extension!\n\nUsage: join-video ${NORMAL}\n" exit 1 fi diff --git a/dotfiles/bin/trim-video-target-rate b/dotfiles/bin/trim-video-target-rate index eb7a41b..4f44016 100644 --- a/dotfiles/bin/trim-video-target-rate +++ b/dotfiles/bin/trim-video-target-rate @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Re-encodes the video using a constrained bitrate/output size. If you want to -# To target the visual quality with a variable bitrate, use trim-video-vbr +# control the visual quality with a variable bitrate then use trim-video-vbr if which tput >/dev/null 2>&1; then ncolors=$(tput colors) diff --git a/dotfiles/bin/trim-video-vbr b/dotfiles/bin/trim-video-vbr index ce6ae41..a7cfed1 100644 --- a/dotfiles/bin/trim-video-vbr +++ b/dotfiles/bin/trim-video-vbr @@ -4,6 +4,8 @@ # To have a mostly fixed bitrate with no variable quality, use trim-video-target-rate # Just note that it'll result in larger files for a similar max bitrate target and the # quality won't really be noticeably better. +# +# The higher the CRF value, the higher the compression. if which tput >/dev/null 2>&1; then ncolors=$(tput colors) @@ -35,11 +37,11 @@ end_time="$4" target_crf="$5" max_bitrate_mb="$6" -default_crf="20" +default_crf="33" # if you want to compress then use the same gpu compression level from compress-video (i.e. 33, but verify it's still set to this) default_max_bitrate="6" if [[ $filename == "" || $output_name == "" || $start_time == "" ]]; then - printf "${BOLD}${RED}Usage: trim-video ${NORMAL}\n" + printf "${BOLD}${RED}Usage: trim-video-vbr ${NORMAL}\n" exit 1 fi