From 83dc20f33e3f90b2faaae1effe7ec3941f74ea86 Mon Sep 17 00:00:00 2001 From: Lydia Vierkorn Date: Thu, 21 May 2026 00:34:48 +0200 Subject: [PATCH] spectrograms: option to use log frequency scale (#1487) --- copyparty/__main__.py | 1 + copyparty/th_srv.py | 11 +++++++++-- 2 files changed, 10 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..f119c5e5 100644 --- a/copyparty/th_srv.py +++ b/copyparty/th_srv.py @@ -467,6 +467,11 @@ class ThumbSrv(object): zs = "th_dec th_no_webp th_no_jpg" for zs in zs.split(" "): ret.append("%s(%s)\n" % (zs, getattr(self.args, zs))) + zs = "th_spec_fl" + for zs in zs.split(" "): + v = getattr(self.args, zs) + if v: + ret.append("%s(%s)\n" % (zs, v)) zs = "th_qv th_qvx thsize th_spec_p convt" for zs in zs.split(" "): ret.append("%s(%s)\n" % (zs, vn.flags.get(zs))) @@ -1056,11 +1061,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"