mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 17:12:13 -06:00
option to disable caf transcoding + misc cleanup
This commit is contained in:
parent
c9eba39edd
commit
f3b9bfc114
|
@ -1373,6 +1373,7 @@ def add_transcoding(ap):
|
||||||
ap2 = ap.add_argument_group('transcoding options')
|
ap2 = ap.add_argument_group('transcoding options')
|
||||||
ap2.add_argument("--q-opus", metavar="KBPS", type=int, default=128, help="target bitrate for transcoding to opus; set 0 to disable")
|
ap2.add_argument("--q-opus", metavar="KBPS", type=int, default=128, help="target bitrate for transcoding to opus; set 0 to disable")
|
||||||
ap2.add_argument("--q-mp3", metavar="QUALITY", type=u, default="q2", help="target quality for transcoding to mp3, for example [\033[32m192k\033[0m] (CBR) or [\033[32mq0\033[0m] (CQ/CRF, q0=maxquality, q9=smallest); set 0 to disable")
|
ap2.add_argument("--q-mp3", metavar="QUALITY", type=u, default="q2", help="target quality for transcoding to mp3, for example [\033[32m192k\033[0m] (CBR) or [\033[32mq0\033[0m] (CQ/CRF, q0=maxquality, q9=smallest); set 0 to disable")
|
||||||
|
ap2.add_argument("--no-caf", action="store_true", help="disable transcoding to caf-opus (iOS v12 and later), use mp3 instead")
|
||||||
ap2.add_argument("--no-acode", action="store_true", help="disable audio transcoding")
|
ap2.add_argument("--no-acode", action="store_true", help="disable audio transcoding")
|
||||||
ap2.add_argument("--no-bacode", action="store_true", help="disable batch audio transcoding by folder download (zip/tar)")
|
ap2.add_argument("--no-bacode", action="store_true", help="disable batch audio transcoding by folder download (zip/tar)")
|
||||||
ap2.add_argument("--ac-maxage", metavar="SEC", type=int, default=86400, help="delete cached transcode output after \033[33mSEC\033[0m seconds")
|
ap2.add_argument("--ac-maxage", metavar="SEC", type=int, default=86400, help="delete cached transcode output after \033[33mSEC\033[0m seconds")
|
||||||
|
|
|
@ -6,7 +6,7 @@ import os
|
||||||
from .__init__ import TYPE_CHECKING
|
from .__init__ import TYPE_CHECKING
|
||||||
from .authsrv import VFS
|
from .authsrv import VFS
|
||||||
from .bos import bos
|
from .bos import bos
|
||||||
from .th_srv import HAVE_WEBP, thumb_path
|
from .th_srv import EXTS_AC, HAVE_WEBP, thumb_path
|
||||||
from .util import Cooldown
|
from .util import Cooldown
|
||||||
|
|
||||||
if True: # pylint: disable=using-constant-test
|
if True: # pylint: disable=using-constant-test
|
||||||
|
@ -57,13 +57,15 @@ class ThumbCli(object):
|
||||||
if is_vid and "dvthumb" in dbv.flags:
|
if is_vid and "dvthumb" in dbv.flags:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
want_opus = fmt in ("opus", "caf", "mp3")
|
want_opus = fmt in EXTS_AC
|
||||||
is_au = ext in self.fmt_ffa
|
is_au = ext in self.fmt_ffa
|
||||||
is_vau = want_opus and ext in self.fmt_ffv
|
is_vau = want_opus and ext in self.fmt_ffv
|
||||||
if is_au or is_vau:
|
if is_au or is_vau:
|
||||||
if want_opus:
|
if want_opus:
|
||||||
if self.args.no_acode:
|
if self.args.no_acode:
|
||||||
return None
|
return None
|
||||||
|
elif fmt == "caf" and self.args.no_caf:
|
||||||
|
fmt = "mp3"
|
||||||
else:
|
else:
|
||||||
if "dathumb" in dbv.flags:
|
if "dathumb" in dbv.flags:
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -46,6 +46,9 @@ HAVE_HEIF = False
|
||||||
HAVE_AVIF = False
|
HAVE_AVIF = False
|
||||||
HAVE_WEBP = False
|
HAVE_WEBP = False
|
||||||
|
|
||||||
|
EXTS_TH = set(["jpg", "webp", "png"])
|
||||||
|
EXTS_AC = set(["opus", "caf", "mp3"])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if os.environ.get("PRTY_NO_PIL"):
|
if os.environ.get("PRTY_NO_PIL"):
|
||||||
raise Exception()
|
raise Exception()
|
||||||
|
@ -139,7 +142,7 @@ def thumb_path(histpath: str, rem: str, mtime: float, fmt: str, ffa: set[str]) -
|
||||||
h = hashlib.sha512(afsenc(fn)).digest()
|
h = hashlib.sha512(afsenc(fn)).digest()
|
||||||
fn = ub64enc(h).decode("ascii")[:24]
|
fn = ub64enc(h).decode("ascii")[:24]
|
||||||
|
|
||||||
if fmt in ("opus", "caf", "mp3"):
|
if fmt in EXTS_AC:
|
||||||
cat = "ac"
|
cat = "ac"
|
||||||
else:
|
else:
|
||||||
fc = fmt[:1]
|
fc = fmt[:1]
|
||||||
|
@ -334,9 +337,10 @@ class ThumbSrv(object):
|
||||||
ap_unpk = abspath
|
ap_unpk = abspath
|
||||||
|
|
||||||
if not bos.path.exists(tpath):
|
if not bos.path.exists(tpath):
|
||||||
want_mp3 = tpath.endswith(".mp3")
|
tex = tpath.rsplit(".", 1)[-1]
|
||||||
want_opus = tpath.endswith(".opus") or tpath.endswith(".caf")
|
want_mp3 = tex == "mp3"
|
||||||
want_png = tpath.endswith(".png")
|
want_opus = tex in ("opus", "caf")
|
||||||
|
want_png = tex == "png"
|
||||||
want_au = want_mp3 or want_opus
|
want_au = want_mp3 or want_opus
|
||||||
for lib in self.args.th_dec:
|
for lib in self.args.th_dec:
|
||||||
can_au = lib == "ff" and (
|
can_au = lib == "ff" and (
|
||||||
|
@ -891,7 +895,7 @@ class ThumbSrv(object):
|
||||||
|
|
||||||
def _clean(self, cat: str, thumbpath: str) -> int:
|
def _clean(self, cat: str, thumbpath: str) -> int:
|
||||||
# self.log("cln {}".format(thumbpath))
|
# self.log("cln {}".format(thumbpath))
|
||||||
exts = ["jpg", "webp", "png"] if cat == "th" else ["opus", "caf", "mp3"]
|
exts = EXTS_TH if cat == "th" else EXTS_AC
|
||||||
maxage = getattr(self.args, cat + "_maxage")
|
maxage = getattr(self.args, cat + "_maxage")
|
||||||
now = time.time()
|
now = time.time()
|
||||||
prev_b64 = None
|
prev_b64 = None
|
||||||
|
|
|
@ -1,11 +1,3 @@
|
||||||
function QSA(x) {
|
|
||||||
return document.querySelectorAll(x);
|
|
||||||
}
|
|
||||||
var LINUX = /Linux/.test(UA),
|
|
||||||
MACOS = /[^a-z]mac ?os/i.test(UA),
|
|
||||||
WINDOWS = /Windows/.test(UA);
|
|
||||||
|
|
||||||
|
|
||||||
var oa = QSA('pre');
|
var oa = QSA('pre');
|
||||||
for (var a = 0; a < oa.length; a++) {
|
for (var a = 0; a < oa.length; a++) {
|
||||||
var html = oa[a].innerHTML,
|
var html = oa[a].innerHTML,
|
||||||
|
|
|
@ -36,7 +36,7 @@ var wah = '',
|
||||||
FIREFOX = ('netscape' in window) && / rv:/.test(UA),
|
FIREFOX = ('netscape' in window) && / rv:/.test(UA),
|
||||||
IPHONE = TOUCH && /iPhone|iPad|iPod/i.test(UA),
|
IPHONE = TOUCH && /iPhone|iPad|iPod/i.test(UA),
|
||||||
LINUX = /Linux/.test(UA),
|
LINUX = /Linux/.test(UA),
|
||||||
MACOS = /[^a-z]mac ?os/i.test(UA),
|
MACOS = /Macintosh/.test(UA),
|
||||||
WINDOWS = /Windows/.test(UA);
|
WINDOWS = /Windows/.test(UA);
|
||||||
|
|
||||||
if (!window.WebAssembly || !WebAssembly.Memory)
|
if (!window.WebAssembly || !WebAssembly.Memory)
|
||||||
|
|
Loading…
Reference in a new issue