Add option to render spectrograms with log frequency scale

This commit is contained in:
Lydia Vierkorn 2026-05-16 00:30:28 +02:00 committed by 9hax
parent 3b53a228b0
commit 6ecc7a8e14
2 changed files with 5 additions and 2 deletions

View file

@ -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

View file

@ -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"