.
This commit is contained in:
@@ -39,6 +39,71 @@ from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Dict, Iterable, List, Optional, Tuple
|
||||
|
||||
|
||||
def ensure_venv_and_reexec():
|
||||
# Already inside a venv?
|
||||
if sys.prefix != sys.base_prefix:
|
||||
return
|
||||
|
||||
script_dir = Path(__file__).resolve().parent
|
||||
|
||||
preferred_venv = script_dir / ".venv"
|
||||
fallback_venv = Path(os.environ.get("XDG_CACHE_HOME", Path.home() / ".cache")) / "py_jellyfin_trickplay_generator" / "venv"
|
||||
|
||||
def venv_python(venv_dir: Path) -> Path:
|
||||
if os.name == "nt":
|
||||
return venv_dir / "Scripts" / "python.exe"
|
||||
return venv_dir / "bin" / "python"
|
||||
|
||||
def is_valid_venv(venv_dir: Path) -> bool:
|
||||
py = venv_python(venv_dir)
|
||||
return py.is_file()
|
||||
|
||||
def recreate_venv(venv_dir: Path) -> None:
|
||||
if venv_dir.exists():
|
||||
shutil.rmtree(venv_dir, ignore_errors=True)
|
||||
venv_dir.parent.mkdir(parents=True, exist_ok=True)
|
||||
subprocess.check_call([sys.executable, "-m", "venv", str(venv_dir)])
|
||||
|
||||
# Pick a venv location that works
|
||||
venv_dir = preferred_venv
|
||||
|
||||
try:
|
||||
if not is_valid_venv(venv_dir):
|
||||
print("[INFO] Creating local virtual environment (.venv)...")
|
||||
recreate_venv(venv_dir)
|
||||
except Exception as e:
|
||||
print(f"[WARN] Failed to create .venv next to script: {e}")
|
||||
venv_dir = fallback_venv
|
||||
if not is_valid_venv(venv_dir):
|
||||
print(f"[INFO] Creating fallback virtual environment at {venv_dir} ...")
|
||||
recreate_venv(venv_dir)
|
||||
|
||||
py = venv_python(venv_dir)
|
||||
if not py.is_file():
|
||||
raise RuntimeError(f"venv python not found after creation: {py}")
|
||||
|
||||
print("[INFO] Ensuring required packages (pillow, rich)...")
|
||||
|
||||
# Ensure pip exists inside venv (some builds need this)
|
||||
subprocess.check_call([str(py), "-m", "ensurepip", "--upgrade"])
|
||||
|
||||
# Upgrade pip + install packages
|
||||
subprocess.check_call([str(py), "-m", "pip", "install", "--upgrade", "pip", "setuptools", "wheel"])
|
||||
subprocess.check_call([str(py), "-m", "pip", "install", "pillow", "rich"])
|
||||
|
||||
print(f"[INFO] Restarting inside virtual environment: {py}")
|
||||
os.execv(str(py), [str(py)] + sys.argv)
|
||||
|
||||
|
||||
|
||||
|
||||
ensure_venv_and_reexec()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
from PIL import Image
|
||||
|
||||
try:
|
||||
@@ -293,15 +358,12 @@ def hw_decode_args(hw: str, hw_device: Optional[str]) -> List[str]:
|
||||
if hw == "vaapi":
|
||||
dev = hw_device or "/dev/dri/renderD128"
|
||||
return [
|
||||
"-init_hw_device",
|
||||
f"vaapi=va:{dev}",
|
||||
"-filter_hw_device",
|
||||
"va",
|
||||
"-hwaccel",
|
||||
"vaapi",
|
||||
"-hwaccel_device",
|
||||
dev,
|
||||
"-hwaccel_output_format",
|
||||
"vaapi",
|
||||
"-noautoscale",
|
||||
]
|
||||
if hw == "qsv":
|
||||
return ["-hwaccel", "qsv", "-noautoscale"]
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
[input]
|
||||
paths =
|
||||
C:\Users\Thorsten\Desktop\Test
|
||||
/home/thorsten/mnt/unRAID/Media/Filme/[Art]/Asian School Girls (2014)/
|
||||
/home/thorsten/mnt/unRAID/Media/Filme/[Art]/Auf die Freude (2023)/
|
||||
|
||||
recursive = true
|
||||
|
||||
@@ -23,4 +24,4 @@ tile_rows = 10
|
||||
ffmpeg =
|
||||
ffprobe =
|
||||
hw = none
|
||||
hw_device =
|
||||
hw_device = /dev/dri/renderD128
|
||||
|
||||
Reference in New Issue
Block a user