Skip to content

Commit

Permalink
Small tweaks to image and audio tooling
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxattax97 committed Sep 29, 2024
1 parent 8eb812e commit fbbacd2
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions .zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,11 @@ zshrc_load_library() {
}
image-optimize() {
mogrify -sampling-factor 4:2:0 -auto-orient -strip -quality 85 -interlace JPEG -colorspace sRGB $@
for file in "$@"; do
# Strip metadata, reduce quality, and convert to sRGB.
magick "$file" -sampling-factor 4:2:0 -auto-orient -strip -quality 85 -interlace JPEG -colorspace sRGB "${file%.*}.jpg"
rm "$file"
done
}
image-shrink() {
Expand All @@ -1364,7 +1368,7 @@ zshrc_load_library() {
}
image-enhance() {
image-shrink $@
#image-shrink $@
image-boost $@
image-optimize $@
}
Expand Down Expand Up @@ -1422,6 +1426,18 @@ zshrc_load_library() {
ssh "$1" "cat $2" | mpv -
}
audio-fade() {
for file in "$@"; do
duration=$(ffprobe -v error -show_entries format=duration "$file" | awk -F'[= ]+' '/duration/{print $2}')
fade_in_start=0
fade_out_start="$(( duration - 1.0 ))"
ffmpeg -i "$file" -af "afade=st=0:d=1:t=in,afade=st=${fade_out_start}:d=1:t=out" "faded_$file"
mv "faded_$file" "$file"
done
}
video-enhance() {
# TODO: auto-pick threads
# TODO: crf to 20?
Expand Down

0 comments on commit fbbacd2

Please sign in to comment.