Skip to content

Windows: escape the metadata path, decode JSON as UTF-8, find a font - #135

Open
DarkStyleee wants to merge 2 commits into
browser-use:mainfrom
DarkStyleee:fix/windows-file-io
Open

Windows: escape the metadata path, decode JSON as UTF-8, find a font#135
DarkStyleee wants to merge 2 commits into
browser-use:mainfrom
DarkStyleee:fix/windows-file-io

Conversation

@DarkStyleee

@DarkStyleee DarkStyleee commented Aug 20, 2026

Copy link
Copy Markdown

Windows failures around paths and text encoding, each one reproduced on this machine. The branch leaves out the stdout reconfigure from #131 and the subtitles path escaping from #128, so it can land on top of either.

grade.py, filter option value. _sample_frame_stats passes a temp file path into metadata=print:file=. Inside a filter option value the drive colon reads as an option separator, so the graph never builds and the analysis dies before a frame is sampled:

[AVFilterGraph] No option name near 'UsersRunnerAppDataLocalTemptmpxp9d38w9.txt'
[AVFilterGraph] Error parsing a filter

The path is now escaped the way render.py escapes the subtitles path, colon and quote both. Verified with --analyze on a real capture: the filter it computes is identical to a run where the path parses.

Reads decoded with the locale codepage. render.py and timeline_view.py load the transcript and the EDL with read_text(). What happens next depends on the bytes, and both outcomes are worse than an obvious error. A real EDL from my project, holding Cyrillic beat labels, dies with UnicodeDecodeError: 'charmap' codec can't decode byte 0x98. A payload that happens to map cleanly comes back as mojibake instead: "привет" reads as "Рїсђрёрірес‚", and the subtitles are built from that. pack_transcripts.py reads the same JSON the same way. All three files are JSON, so UTF-8 is the only correct decoding.

Writes encoded with the locale codepage. The concat list is written with write_text(), so a segment under a non-ASCII path is written in a form ffmpeg won't open ("Impossible to open ..."), and the concat stops. Written as UTF-8, the same list works. The master SRT has the same bug with a worse ending, because it's the artifact the viewer sees: libass reads it as UTF-8 and the subtitles come out garbled. #131 carries that one line as well; it's here so this branch fixes reading and writing together rather than half of each.

timeline_view.py, fonts. FONT_CANDIDATES lists macOS and Linux paths only. load_font falls back to ImageFont.load_default(), so the timeline still renders, in a bitmap font at a fixed size. Consolas and Arial appended.

Windows 11, Python 3.11.9, ffmpeg N-121793.

…font on Windows

Three small Windows failures, none of them covered by browser-use#131 or browser-use#128.

grade.py passed a temp file path straight into metadata=print:file=. Inside a
filter option value the drive colon reads as an option separator, so ffmpeg
reports "No option name near 'UsersRunner...'" and the analysis dies before a
single frame is sampled. The path is now escaped the way render.py already
escapes the subtitles path. Verified with --analyze on a real capture: the
filter it computes is byte-identical to the one from a run where the path
parses.

render.py and timeline_view.py read the transcript and the EDL with read_text(),
which decodes with the locale codepage. This does not raise on a non-ASCII
transcript, which would at least be visible. On cp1251 it returns mojibake:
"привет" comes back as "Рїсђрёрірес‚", and the subtitles are built from that.
Both files are JSON, so UTF-8 is the only correct decoding.

FONT_CANDIDATES listed macOS and Linux paths only. load_font falls back to
ImageFont.load_default(), so the timeline still renders, in a bitmap font at a
fixed size. Consolas and Arial appended.

@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.

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread helpers/render.py
Comment thread helpers/timeline_view.py
Comment thread helpers/grade.py
…oted path

Review on browser-use#135 pointed at the write side and at a gap in the escaping.

The concat list is written with the locale codepage, so a segment under a path
with non-ASCII characters is written in a form ffmpeg cannot open: "Impossible to
open ..." and the render stops. The same list written as UTF-8 concatenates. This
is the write half of the read fix already in this branch.

The master SRT had the same problem with a worse ending, since it is the artifact
the viewer sees: written in a codepage, libass reads it as UTF-8 and the subtitles
come out as mojibake. browser-use#131 carries this one line too. Keeping it here so the
branch fixes reading and writing together rather than half of each.

pack_transcripts.py reads the same transcript JSON with the locale codepage. What
transcribe.py writes is ASCII-escaped by json.dumps, so this one needs an
externally produced transcript to bite, but the read should still name UTF-8.

_esc_filter_path escaped the drive colon but not the quote, while the value it
produces is wrapped in single quotes. A temp path under a user named O'Brien
would close the quoted section early. render.py escapes both; now this does too.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant