From 1a00e30b8722a54f8ba318ecf4f5a9d2281ee8cc Mon Sep 17 00:00:00 2001 From: dongxiaoman Date: Tue, 5 May 2026 17:47:37 -0700 Subject: [PATCH] try out fix --- video_has_audio_node.py | 47 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/video_has_audio_node.py b/video_has_audio_node.py index 18cd194..ec50207 100644 --- a/video_has_audio_node.py +++ b/video_has_audio_node.py @@ -1,6 +1,12 @@ import subprocess import json import shutil +import os + +try: + import folder_paths +except ImportError: + folder_paths = None class VideoHasAudioNode: @@ -29,10 +35,49 @@ class VideoHasAudioNode: has_audio = self._probe_has_audio(input_file) return (has_audio, 1 if has_audio else 0) + def _resolve_path(self, input_file): + if os.path.isabs(input_file) and os.path.exists(input_file): + return input_file + + if folder_paths is not None: + try: + annotated = folder_paths.get_annotated_filepath(input_file) + if annotated and os.path.exists(annotated): + return annotated + except Exception: + pass + + candidate_dirs = [] + for getter in ("get_input_directory", "get_output_directory", "get_temp_directory"): + fn = getattr(folder_paths, getter, None) + if fn is not None: + try: + candidate_dirs.append(fn()) + except Exception: + pass + + for d in candidate_dirs: + if not d: + continue + candidate = os.path.join(d, input_file) + if os.path.exists(candidate): + return candidate + + if os.path.exists(input_file): + return input_file + + return None + def _probe_has_audio(self, input_file): if not input_file or not input_file.strip(): return False + resolved = self._resolve_path(input_file.strip()) + if resolved is None: + raise RuntimeError( + f"Video file not found: '{input_file}'. Checked absolute path and ComfyUI input/output/temp directories." + ) + ffprobe = shutil.which("ffprobe") or "ffprobe" cmd = [ ffprobe, @@ -40,7 +85,7 @@ class VideoHasAudioNode: "-select_streams", "a", "-show_entries", "stream=index", "-of", "json", - input_file, + resolved, ] try: