From 4729c75e417c6d00e5113e7ac44c46253620274e Mon Sep 17 00:00:00 2001 From: bnair Date: Sat, 3 Jan 2026 13:01:54 +0100 Subject: [PATCH] Fixed prio and locks --- src/vmaf_common.py | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/src/vmaf_common.py b/src/vmaf_common.py index 8a362a2..e3ee0b3 100644 --- a/src/vmaf_common.py +++ b/src/vmaf_common.py @@ -34,8 +34,34 @@ def get_base_paths(args=None): tv_dir = Path(args.tv_dir) if args and hasattr(args, 'tv_dir') else Path(DEFAULT_CONFIG["tv_dir"]) # Logic: Locks MUST be at the common root of content to be shared. - # We assume tv_dir is like "Z:\tv", so shared root is "Z:\" - shared_root = tv_dir.parent + # We attempt to find the common parent if both are supplied, otherwise default to tv_dir parent. + + potential_roots = [] + if args: + if hasattr(args, 'tv_dir') and args.tv_dir: potential_roots.append(Path(args.tv_dir)) + if hasattr(args, 'content_dir') and args.content_dir: potential_roots.append(Path(args.content_dir)) + + if not potential_roots: + potential_roots.append(Path(DEFAULT_CONFIG["tv_dir"])) + + # Find common path + try: + if len(potential_roots) > 1: + # If they are on different drives, common_path might fail or return empty on Windows + # In that case, we fall back to the first one (TV dir parent) + common_root = os.path.commonpath(potential_roots) + shared_root = Path(common_root) + # If common root is the root drive itself (e.g. Z:\), that's fine. + # If it's a subdir (Z:\Media), also fine. + # But if it's too deep (e.g. just Z:\), we want to make sure we don't dump .vmaf_locks in root unless intended. + # Typically, we want the parent of the library folders. + # If os.path.commonpath returns Z:\Media, and dirs are Z:\Media\TV and Z:\Media\Content + # Then locks go to Z:\Media\.vmaf_locks. Perfect. + else: + shared_root = potential_roots[0].parent + except: + # Fallback for different drives + shared_root = potential_roots[0].parent # Defaults lock_dir = Path("locks").resolve() @@ -195,16 +221,16 @@ def detect_hardware_encoder(args=None): hevc_enc = None hw_type = "cpu" - # 1. NVIDIA (NVENC) - Windows/Linux - if "av1_nvenc" in out: av1_enc = "av1_nvenc" - if "hevc_nvenc" in out: hevc_enc = "hevc_nvenc" - if av1_enc or hevc_enc: return av1_enc, hevc_enc, "nvenc" - - # 2. AMD (AMF) - Windows + # 1. AMD (AMF) - Windows (Preferred) if "av1_amf" in out: av1_enc = "av1_amf" if "hevc_amf" in out: hevc_enc = "hevc_amf" if av1_enc or hevc_enc: return av1_enc, hevc_enc, "amf" + # 2. NVIDIA (NVENC) - Windows/Linux + if "av1_nvenc" in out: av1_enc = "av1_nvenc" + if "hevc_nvenc" in out: hevc_enc = "hevc_nvenc" + if av1_enc or hevc_enc: return av1_enc, hevc_enc, "nvenc" + # 3. AMD (VAAPI) - Linux # Often named hevc_vaapi, av1_vaapi if "av1_vaapi" in out: av1_enc = "av1_vaapi"