#193·video-use

Windows: multiple helpers break on non-ASCII (e.g. Korean) paths — missing encoding="utf-8"

Author: baik9208-codeCreated Sep 27, 2026Updated Sep 27, 2026

Summary

Several helper scripts break on Windows when the repo/project lives under a path containing non-ASCII characters (tested with Korean, but any non-ASCII path is likely affected). Root cause: multiple Path.read_text() / Path.write_text() calls and subprocess.run(..., text=True) calls don't pass encoding="utf-8", so Python falls back to the OS locale encoding (cp949 on Korean Windows), which mangles or crashes on the path/output.

Repro: clone the repo anywhere under a Korean-named directory (or any non-ASCII path) on Windows, run through transcribe.py → render.py on a short clip.

Failures observed

  1. render.py concat_segments() — concat_list.write_text(...) (no encoding) writes the ffmpeg concat list with mangled paths → ffmpeg -f concat fails with Impossible to open '...'.
  2. render.py subtitles filter — builds an absolute Windows path (with drive-letter colon and, in our case, Korean directory names) directly into the subtitles='...' filtergraph string. Even after escaping :, libass/ffmpeg failed to open the file reliably on Windows with non-ASCII path components.
  3. render.py measure_loudness() / other subprocess.run(..., text=True) calls (loudnorm measurement, ffprobe helpers) — no encoding= on text=True, so decoding ffmpeg's stderr (which echoes the input path) raises UnicodeDecodeError: 'cp949' codec can't decode byte ....
  4. render.py master SRT write, pack_transcripts.py, timeline_view.py, transcribe.py — read_text()/write_text() calls without encoding="utf-8".

Suggested fix

  • Add encoding="utf-8" to every Path.read_text() / Path.write_text() call in helpers/.
  • Add encoding="utf-8", errors="replace" to every subprocess.run(..., text=True, ...) call.
  • For the subtitles filter in build_final_composite(): run the ffmpeg subprocess with cwd=edit_dir and pass the subtitles filter path relative to edit_dir (just the filename, e.g. master.srt) instead of an absolute path. This sidesteps both the :/\ escaping issues in ffmpeg's filtergraph mini-language and libass's apparent trouble with non-ASCII absolute paths on Windows — and it's simpler than escaping.

We patched a local clone with exactly these changes and confirmed a full transcribe.py → build EDL → render.py --preview --build-subtitles run completes successfully (Korean subtitles burn in correctly, loudnorm two-pass runs, final.mp4 produced) on a path like F:\<Korean folder name>\...\edit\. Happy to open a PR with the diff if useful — flagging as an issue first in case there's a preferred approach (e.g. wrapping in a helper, or setting PYTHONUTF8=1 at entry instead of per-call).

Environment

  • Windows 11, Python 3.12 (via uv), ffmpeg 9.0.1 (gyan.dev full build)
  • Repo path contains Korean characters (non-ASCII)