diff --git a/copyparty/cfg.py b/copyparty/cfg.py index d8f42a0e..9737f92b 100644 --- a/copyparty/cfg.py +++ b/copyparty/cfg.py @@ -190,6 +190,7 @@ flagcats = { "dvthumb": "disables video thumbnails", "dathumb": "disables audio thumbnails (spectrograms)", "dithumb": "disables image thumbnails", + "pngquant": "compress audio waveforms 33% better", "thsize": "thumbnail res; WxH", "crop": "center-cropping (y/n/fy/fn)", "th3x": "3x resolution (y/n/fy/fn)", diff --git a/copyparty/th_srv.py b/copyparty/th_srv.py index 3208ec12..c35010bb 100644 --- a/copyparty/th_srv.py +++ b/copyparty/th_srv.py @@ -593,6 +593,24 @@ class ThumbSrv(object): cmd += [fsenc(tpath)] self._run_ff(cmd, vn) + if "pngquant" in vn.flags: + wtpath = tpath + ".png" + cmd = [ + b"pngquant", + b"--strip", + b"--nofs", + b"--output", fsenc(wtpath), + fsenc(tpath) + ] + ret = runcmd(cmd, timeout=vn.flags["convt"], nice=True, oom=400)[0] + if ret: + try: + wunlink(self.log, wtpath, vn.flags) + except: + pass + else: + wrename(self.log, wtpath, tpath, vn.flags) + def conv_spec(self, abspath: str, tpath: str, fmt: str, vn: VFS) -> None: ret, _ = ffprobe(abspath, int(vn.flags["convt"] / 2)) if "ac" not in ret: