Skip to content

Fix frame extraction with '%' in the output path, and caption pick when several -orig tracks exist - #259

Open
MrAndyPuppy wants to merge 2 commits into
bradautomates:mainfrom
MrAndyPuppy:andrew/percent-path-fix
Open

MrAndyPuppy wants to merge 2 commits into
bradautomates:mainfrom
MrAndyPuppy:andrew/percent-path-fix

Conversation

@MrAndyPuppy

Copy link
Copy Markdown

What changed

  1. frames.py — escape % in the output directory. ffmpeg's image2 muxer treats every % in the output path as a sequence-pattern token. A work dir named after a video such as "Get Ahead of 95% in 11 Minutes" made ffmpeg write a single literal frame_%04d.jpg (or fail), so no frames were extracted. All three frame_%04d.jpg call sites now go through a small _frame_pattern() helper that escapes % as %%.

  2. download.py — pick the right original caption track. In auto mode, select_caption() replaced the language match with originals[0], the alphabetically first -orig track. Some videos list several: https://youtu.be/yf2OwchM9nw is en-US but offers both ar-orig and en-orig, so /watch returned an Arabic transcript. (YouTube's own player also defaults to Arabic captions on this video.) With several originals it now prefers the one matching the metadata language, else English-first. A single original still overrides dubbed metadata exactly as before, so test_original_track_overrides_dubbed_metadata is unchanged.

Tests

  • One regression test per fix (test_percent_in_output_dir_is_literal across the keyframe and scene/uniform engines; test_multiple_originals_follow_metadata_language). Each fails without its fix.
  • Full suite on Windows (Python 3.14, FFmpeg 8.1.1): 248 passed, 6 skipped.
  • End-to-end check on the video above with --start 0:30 --end 1:00 and an --out-dir containing 95%: 60 frames, English captions (en-orig).

🤖 Generated with Claude Code

Andrew Parsons and others added 2 commits October 16, 2026 20:01
ffmpeg's image2 muxer parses every '%' in the output path as part of
the sequence pattern. A work dir named after a video such as
"Get Ahead of 95% in 11 Minutes" made ffmpeg write a single literal
frame_%04d.jpg (or fail), so no frames were extracted. All three
frame_%04d.jpg call sites now go through _frame_pattern(), which
escapes '%' as '%%'. Adds a regression test across the keyframe and
scene/uniform engines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
select_caption() replaced any auto-mode match with originals[0], the
alphabetically first '-orig' track. Some YouTube videos list more than
one original ASR track (youtu.be/yf2OwchM9nw, an en-US video, offers
both ar-orig and en-orig), so watch returned an Arabic transcript.

With several originals, prefer the one matching the metadata language,
else English-first. A single original still overrides dubbed metadata,
as before. Adds a regression test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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