From 6ecc7a8e14f6268aa30277b43017aae10d52cd64 Mon Sep 17 00:00:00 2001 From: Lydia Vierkorn Date: Sat, 16 May 2026 00:30:28 +0200 Subject: [PATCH] Add option to render spectrograms with log frequency scale --- copyparty/__main__.py | 1 + copyparty/th_srv.py | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/copyparty/__main__.py b/copyparty/__main__.py index 2f568b5c..1833aaec 100644 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -1769,6 +1769,7 @@ def add_thumbnail(ap): ap2.add_argument("--th-pre-rl", metavar="SEC", type=int, default=30, help="while pregen is running, ratelimit the thumbnailer logger to one message every \033[33mSEC\033[0m seconds (only works with \033[33m-j1\033[0m); set 0 to disable ratelimit") ap2.add_argument("--th-covers", metavar="N,N", type=u, default="folder.png,folder.jpg,cover.png,cover.jpg", help="folder thumbnails to stat/look for; enabling \033[33m-e2d\033[0m will make these case-insensitive, and try them as dotfiles (.folder.jpg), and also automatically select thumbnails for all folders that contain pics, even if none match this pattern") ap2.add_argument("--th-spec-p", metavar="N", type=u, default=1, help="for music, do spectrograms or embedded coverart? [\033[32m0\033[0m]=only-art, [\033[32m1\033[0m]=prefer-art, [\033[32m2\033[0m]=only-spec") + ap2.add_argument("--th-spec-fl", action="store_true", help="generate spectrograms with logarithmic frequency scale instead of linear") # https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html # https://github.com/libvips/libvips # https://stackoverflow.com/a/47612661 diff --git a/copyparty/th_srv.py b/copyparty/th_srv.py index 397f055d..6d34a4e9 100644 --- a/copyparty/th_srv.py +++ b/copyparty/th_srv.py @@ -1056,11 +1056,13 @@ class ThumbSrv(object): # fmt: on self._run_ff(cmd, vn, "convt") + fscale = ":fscale=log" if self.args.th_spec_fl else "" + fc = "[0:a:0]aresample=48000{},showspectrumpic=s=" if "3" in fmt: - fc += "1280x1024,crop=1420:1056:70:48[o]" + fc += "1280x1024%s,crop=1420:1056:70:48[o]" % fscale else: - fc += "640x512,crop=780:544:70:48[o]" + fc += "640x512%s,crop=780:544:70:48[o]" % fscale if self.args.th_ff_swr: fco = ":filter_size=128:cutoff=0.877"