Skip to content

fix(render): escape apostrophes in concat demuxer list#54

Open
sidorovanthon wants to merge 1 commit into
browser-use:mainfrom
sidorovanthon:fix/concat-apostrophe-escaping
Open

fix(render): escape apostrophes in concat demuxer list#54
sidorovanthon wants to merge 1 commit into
browser-use:mainfrom
sidorovanthon:fix/concat-apostrophe-escaping

Conversation

@sidorovanthon

@sidorovanthon sidorovanthon commented Jun 1, 2026

Copy link
Copy Markdown

Problem

concat_segments in helpers/render.py writes the ffmpeg concat-demuxer list as:

concat_list.write_text("".join(f"file '{p.resolve()}'\n" for p in segment_paths))

When the resolved path contains a literal apostrophe — which is common for English video-folder names (e.g. 2026-03-12 What else I couldn't yet do with the help of AI/) — the apostrophe closes the single-quoted string early. ffmpeg then parses a truncated path and the concat step fails:

concat → base.mp4
subprocess.CalledProcessError: Command '[...ffmpeg... -f concat ...]' returned non-zero exit status ...

This is especially confusing because the per-segment extracts all succeed — the failure only surfaces at the join, after the slow part of the pipeline has already run.

Fix

Escape ' as '\'' (close quote, escaped quote, reopen quote), which is the quoting the concat demuxer line format expects:

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))

Repro

Run any EDL whose source/edit directory path contains an apostrophe. Before the fix, concat fails; after, base.mp4 is produced normally. Verified end-to-end on a real 1080×1920 vertical render whose folder name contained "couldn't".

🤖 Generated with Claude Code


Summary by cubic

Escape apostrophes in segment paths when generating the ffmpeg concat-demuxer list to prevent truncated paths and failed joins. Adds proper '\'' quoting via a small helper in concat_segments so paths containing ' concat successfully.

Written for commit 60f1a50. Summary will update on new commits.

Review in cubic

concat_segments wrote each segment path into the ffmpeg concat list as
`file '<path>'`. 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) <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant