feat: pass WAV paths as CLI args to verify_sync

This commit is contained in:
Honney OC committed 2026-09-14 02:36:34 +00:00
1 parent 5ec94cc4dd
commit bfd0546717
2 files changed
+19 -12

No files matched your search

+3
View File
@@ -432,6 +432,8 @@ class SyncWindow(QtWidgets.QMainWindow):
import subprocess import subprocess
script = os.path.join(os.path.dirname(__file__), "verify_sync.py") script = os.path.join(os.path.dirname(__file__), "verify_sync.py")
cmd = [sys.executable, script, "--config", "config.toml", cmd = [sys.executable, script, "--config", "config.toml",
"--a", self.video_a, "--b", self.video_b,
"--wav-a", self.a_path, "--wav-b", self.b_path,
"--lag", f"{self.lag_sec:.6f}", "--mode", "short"] "--lag", f"{self.lag_sec:.6f}", "--mode", "short"]
print(f"Launching: {' '.join(cmd)}") print(f"Launching: {' '.join(cmd)}")
subprocess.Popen(cmd, cwd=os.path.dirname(os.path.abspath(__file__))) subprocess.Popen(cmd, cwd=os.path.dirname(os.path.abspath(__file__)))
@@ -454,6 +456,7 @@ class SyncWindow(QtWidgets.QMainWindow):
# Launch verify in full mode # Launch verify in full mode
cmd2 = [sys.executable, verify_script, "--config", "config.toml", cmd2 = [sys.executable, verify_script, "--config", "config.toml",
"--a", self.video_a, "--b", self.video_b,
"--lag", f"{self.lag_sec:.6f}", "--mode", "full"] "--lag", f"{self.lag_sec:.6f}", "--mode", "full"]
print(f"Launching: {' '.join(cmd2)}") print(f"Launching: {' '.join(cmd2)}")
subprocess.Popen(cmd2, cwd=script_dir) subprocess.Popen(cmd2, cwd=script_dir)
+16 -12
View File
@@ -652,6 +652,8 @@ def main():
ap.add_argument("--config", default="config.toml") ap.add_argument("--config", default="config.toml")
ap.add_argument("--a", default=None, help="Video file A") ap.add_argument("--a", default=None, help="Video file A")
ap.add_argument("--b", default=None, help="Video file B") ap.add_argument("--b", default=None, help="Video file B")
ap.add_argument("--wav-a", default=None, help="WAV file for audio A")
ap.add_argument("--wav-b", default=None, help="WAV file for audio B")
ap.add_argument("--synced", default=None, help="Synced MKV output (full mode)") ap.add_argument("--synced", default=None, help="Synced MKV output (full mode)")
ap.add_argument("--lag", type=float, default=0.0, help="Lag in seconds") ap.add_argument("--lag", type=float, default=0.0, help="Lag in seconds")
ap.add_argument("--mode", choices=["short", "full"], default="short", ap.add_argument("--mode", choices=["short", "full"], default="short",
@@ -679,10 +681,12 @@ def main():
except Exception: except Exception:
pass pass
ext = cfg.get("extract", {})
if args.mode == "full": if args.mode == "full":
synced = args.synced synced = args.synced
if not synced: if not synced:
video_a = ext.get("file_a", "") video_a = args.a or ext.get("file_a", "")
stem = os.path.splitext(os.path.basename(video_a))[0] stem = os.path.splitext(os.path.basename(video_a))[0]
synced = os.path.join(out_dir, f"{stem}_synced.mkv") synced = os.path.join(out_dir, f"{stem}_synced.mkv")
if not os.path.exists(synced): if not os.path.exists(synced):
@@ -701,8 +705,7 @@ def main():
# Determine which streams to extract from synced MKV # Determine which streams to extract from synced MKV
# A's streams are first, B's delayed streams follow # A's streams are first, B's delayed streams follow
ext = cfg.get("extract", {}) video_a = args.a or ext.get("file_a", "")
video_a = ext.get("file_a", "")
a_streams_in = probe_audio_streams(video_a) if os.path.exists(video_a) else [] a_streams_in = probe_audio_streams(video_a) if os.path.exists(video_a) else []
n_a = len(a_streams_in) n_a = len(a_streams_in)
sel_a = _state.get("audio_stream_a", 0) or 0 sel_a = _state.get("audio_stream_a", 0) or 0
@@ -745,18 +748,19 @@ def main():
else: else:
video_a = args.a or ext.get("file_a", "") video_a = args.a or ext.get("file_a", "")
video_b = args.b or ext.get("file_b", "") video_b = args.b or ext.get("file_b", "")
out_dir_extract = ext.get("out_dir", "extracted") out_dir_extract = ext.get("out_dir", "extracted")
def find_wav(video_path: str) -> str: if args.wav_a:
if not video_path: wav_a = args.wav_a
return "" else:
stem = os.path.splitext(os.path.basename(video_path))[0] stem_a = os.path.splitext(os.path.basename(video_a))[0]
cand = os.path.join(out_dir_extract, f"{stem}_audio.wav") wav_a = os.path.join(out_dir_extract, f"{stem_a}_audio.wav")
return cand if os.path.exists(cand) else cand
wav_a = find_wav(video_a) if args.wav_b:
wav_b = find_wav(video_b) wav_b = args.wav_b
else:
stem_b = os.path.splitext(os.path.basename(video_b))[0]
wav_b = os.path.join(out_dir_extract, f"{stem_b}_audio.wav")
if not video_a or not os.path.exists(video_a): if not video_a or not os.path.exists(video_a):
print(f"ERROR: video A not found: {video_a}", file=sys.stderr); sys.exit(1) print(f"ERROR: video A not found: {video_a}", file=sys.stderr); sys.exit(1)