From 60f1a5054b91c0b209a54767a09e1c20fc9fe77f Mon Sep 17 00:00:00 2001 From: Anton Sidorov aka anticodeguy Date: Mon, 1 Jun 2026 09:53:53 +0700 Subject: [PATCH] fix(render): escape apostrophes in concat demuxer list concat_segments wrote each segment path into the ffmpeg concat list as `file ''`. A literal apostrophe in the path (e.g. a videos folder whose name contains "couldn't") closes the single-quoted string early, so ffmpeg parses a truncated path and the concat step fails with a non-zero exit -- while the per-segment extracts all succeed, which makes it look like the cut worked right up until the join. Escape ' as '\'' (close quote, escaped quote, reopen quote), the quoting the concat demuxer line format expects. Co-Authored-By: Claude Opus 4.8 (1M context) --- helpers/render.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/helpers/render.py b/helpers/render.py index 0d02cff..0f04c98 100644 --- a/helpers/render.py +++ b/helpers/render.py @@ -268,7 +268,13 @@ def concat_segments(segment_paths: list[Path], out_path: Path, edit_dir: Path) - """Lossless concat via the concat demuxer. No re-encode.""" out_path.parent.mkdir(parents=True, exist_ok=True) concat_list = edit_dir / "_concat.txt" - concat_list.write_text("".join(f"file '{p.resolve()}'\n" for p in segment_paths)) + # Escape single quotes for the concat demuxer line format. A literal ' inside + # a single-quoted path must be written as '\'' (close quote, escaped quote, + # reopen quote); otherwise a path containing an apostrophe (e.g. a folder + # named "What I couldn't do") truncates the path and ffmpeg fails to concat. + def _concat_quote(p: Path) -> str: + return str(p.resolve()).replace("'", "'\\''") + concat_list.write_text("".join(f"file '{_concat_quote(p)}'\n" for p in segment_paths)) cmd = [ "ffmpeg", "-y",