adjust stopping behavior
This commit is contained in:
+9
-28
@@ -10,10 +10,9 @@ from datetime import datetime
|
||||
import shutil
|
||||
import time
|
||||
|
||||
# Distributed encode defaults (AV1 libaom: crf 0, maxrate 9000k; -cpu-used 8 = faster, -threads 0 = use all cores; override via DISTRIBUTED_REMOTE_ARGS).
|
||||
# Distributed mode requires tqdm and ffmpeg_distributed.py (SSH, Unix select.poll); on Windows use WSL or Linux.
|
||||
DISTRIBUTED_HOSTS_DEFAULT = ["Pyro", "RenderScrap", "root@GuiltsCurse", "PostIrony", "root@Godzilla"]
|
||||
DISTRIBUTED_REMOTE_ARGS_DEFAULT = "-c:v libaom-av1 -crf 0 -b:v 9000k -maxrate 9000k -bufsize 18000k -cpu-used 8 -threads 0 -an"
|
||||
DISTRIBUTED_REMOTE_ARGS_DEFAULT = "-c:v libaom-av1 -crf 0 -b:v 9000k -maxrate 9000k -bufsize 18000k -cpu-used 8 -row-mt 1 -an"
|
||||
DISTRIBUTED_SEGMENT_SECONDS = 60
|
||||
|
||||
# ANSI color codes
|
||||
@@ -393,36 +392,21 @@ def encode_dvr_distributed(input_file, output_dir, hosts, segment_seconds=60, re
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
use_distributed = "--distributed" in sys.argv or "-d" in sys.argv
|
||||
if "--distributed" in sys.argv:
|
||||
sys.argv.remove("--distributed")
|
||||
if "-d" in sys.argv:
|
||||
sys.argv.remove("-d")
|
||||
|
||||
if not use_distributed:
|
||||
choice = input(f"\n{Colors.BLUE}Encode mode: [L]ocal (NVENC) / [D]istributed (farm):{Colors.ENDC} ").strip().upper() or "L"
|
||||
use_distributed = choice == "D"
|
||||
|
||||
if use_distributed and sys.platform == "win32":
|
||||
if sys.platform == "win32":
|
||||
print(f"{Colors.YELLOW}Distributed mode uses select.poll() and may fail on Windows; use WSL or Linux for best results.{Colors.ENDC}")
|
||||
|
||||
input_dir = "input"
|
||||
output_dir = "output"
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
|
||||
if use_distributed:
|
||||
hosts_str = os.environ.get("DISTRIBUTED_HOSTS")
|
||||
if hosts_str:
|
||||
hosts = [h.strip() for h in hosts_str.split(",") if h.strip()]
|
||||
else:
|
||||
hosts = DISTRIBUTED_HOSTS_DEFAULT
|
||||
print(f"{Colors.BLUE}Using hosts: {', '.join(hosts)}{Colors.ENDC}")
|
||||
safe_log_info(f"Distributed mode; hosts: {hosts}")
|
||||
hosts_str = os.environ.get("DISTRIBUTED_HOSTS")
|
||||
if hosts_str:
|
||||
hosts = [h.strip() for h in hosts_str.split(",") if h.strip()]
|
||||
else:
|
||||
gpu = get_gpu_selection()
|
||||
safe_log_info(f"Selected GPU: {gpu}")
|
||||
hosts = DISTRIBUTED_HOSTS_DEFAULT
|
||||
print(f"{Colors.BLUE}Using hosts: {', '.join(hosts)}{Colors.ENDC}")
|
||||
safe_log_info(f"Distributed mode; hosts: {hosts}")
|
||||
|
||||
# Get list of files to process
|
||||
files = [f for f in os.listdir(input_dir) if f.endswith(('.mp4', '.DVR.mp4'))]
|
||||
total_files = len(files)
|
||||
|
||||
@@ -435,7 +419,4 @@ if __name__ == "__main__":
|
||||
input_file = os.path.join(input_dir, file)
|
||||
safe_log_info(f"Processing file {i}/{total_files}: {file}")
|
||||
print(f"\n{Colors.BLUE}Processing file {i}/{total_files}: {file}{Colors.ENDC}")
|
||||
if use_distributed:
|
||||
encode_dvr_distributed(input_file, output_dir, hosts, segment_seconds=DISTRIBUTED_SEGMENT_SECONDS)
|
||||
else:
|
||||
encode_dvr(input_file, output_dir, gpu)
|
||||
encode_dvr_distributed(input_file, output_dir, hosts, segment_seconds=DISTRIBUTED_SEGMENT_SECONDS)
|
||||
Reference in New Issue
Block a user