From 4e0150adc342545709937d9c2c33dddea9896275 Mon Sep 17 00:00:00 2001 From: calesthio Date: Thu, 13 Aug 2026 09:08:00 -0700 Subject: [PATCH] fix: probe Ark audio data URIs on Windows --- tools/video/seedance_ark.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/video/seedance_ark.py b/tools/video/seedance_ark.py index f6843fd4..8412d8a1 100644 --- a/tools/video/seedance_ark.py +++ b/tools/video/seedance_ark.py @@ -1194,10 +1194,17 @@ class SeedanceArkVideo(BaseTool): def _probe_audio_bytes(self, decoded: bytes, mime: str) -> float: suffix = ".wav" if mime == "audio/wav" else ".mp3" - with tempfile.NamedTemporaryFile(suffix=suffix) as temp: + # Windows does not allow ffprobe to reopen a NamedTemporaryFile while + # Python still holds the file handle. Close it before probing, then + # remove it explicitly on every path. + with tempfile.NamedTemporaryFile(suffix=suffix, delete=False) as temp: temp.write(decoded) temp.flush() - return self._probe_local_audio_duration(Path(temp.name)) + temp_path = Path(temp.name) + try: + return self._probe_local_audio_duration(temp_path) + finally: + temp_path.unlink(missing_ok=True) @staticmethod def _probe_local_audio_duration(path: Path) -> float: