From 9f5ba139d42107787296aa877b44ef5a79b86c2f Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 1 Jan 2025 22:29:33 +0000 Subject: [PATCH] [file_previewer.sh]: Add waveform preview to audio files --- src/file_previewer.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/file_previewer.sh b/src/file_previewer.sh index 484d4ce..e37abb9 100755 --- a/src/file_previewer.sh +++ b/src/file_previewer.sh @@ -49,7 +49,11 @@ case "$mimetype" in unzip -lv "$file" | bat --theme='base16' --terminal-width "$(($width-4))" --force-colorization;; audio/*) - exiftool -Picture -b "$file" | chafa --size "$(($width-4))"x"$height" || chafa cover.* --size "$(($width-4))"x"$height" + # attempt to preview the audio file's embedded image + ## if no embedded image, attempt to preview a file named 'cover.*' in the same directory + # else, generate a waveform image and display it + # exiftool -Picture -b "$file" | chafa --size "$(($width-4))"x"$height" || chafa cover.* --size "$(($width-4))"x"$height" || ffmpeg -i "$file" -filter_complex "showwavespic=s=1280x720:colors=white" -frames:v 1 -f image2pipe -vcodec png - | chafa --size "$(($width-4))"x"$height" + exiftool -Picture -b "$file" | chafa --size "$(($width-4))"x"$height" || chafa cover.* --size "$(($width-4))"x"$height" || ffmpeg -i "$file" -filter_complex "showwavespic=s=1280x720:colors=pink" -frames:v 1 -f image2pipe -vcodec png - | chafa --size "$(($width-4))"x"$height" exiftool "$file" | bat --theme='base16' --terminal-width "$(($width-4))" --force-colorization;; image/*)