Skip to content

fix: log on read_video_frame_at failure; os.path.join in stitch_video#155

Merged
nikopueringer merged 1 commit intonikopueringer:mainfrom
shezmic:fix/frame-io-logging-ffmpeg-path
Mar 14, 2026
Merged

fix: log on read_video_frame_at failure; os.path.join in stitch_video#155
nikopueringer merged 1 commit intonikopueringer:mainfrom
shezmic:fix/frame-io-logging-ffmpeg-path

Conversation

@shezmic
Copy link
Contributor

@shezmic shezmic commented Mar 13, 2026

What changed

Two small fixes in backend/ — no logic changes.

1. backend/frame_io.py — silent None in read_video_frame_at()

When cap.read() fails (bad seek, truncated video, corrupted file), read_video_frame_at() returned None with no log output. Its sibling read_image_frame() already emits logger.warning("Could not read frame: %s", fpath) in the same situation. read_video_frame_at() was inconsistent — the failure was completely invisible to callers and log handlers.

Added logger.warning("Could not read video frame %d from: %s", frame_index, video_path) immediately before the return None, matching the existing pattern.

2. backend/ffmpeg_tools.py — hardcoded / in stitch_video()

The FFmpeg -i input path was built with string concatenation (in_dir + "/" + pattern), the only remaining hardcoded slash in the file after the os.path.join fixes in PR #100. Replaced with os.path.join(in_dir, pattern); os is already imported at line 15.

Why it was needed

  • Silent None returns make debugging failed video reads difficult — there's no log message to indicate which file or frame index caused the problem.
  • Hardcoded / breaks on Windows paths; the rest of ffmpeg_tools.py already uses os.path.join consistently.

How to verify

uv run pytest          # 221 passed, 2 skipped
uv run ruff check backend/frame_io.py backend/ffmpeg_tools.py   # All checks passed

Two small fixes in backend/:

1. backend/frame_io.py — read_video_frame_at() returned None silently
   when cap.read() failed (bad seek or truncated video). Unlike its
   sibling read_image_frame(), no warning was emitted, making the failure
   invisible to callers and log aggregation. Added logger.warning() with
   the frame index and path, matching the existing pattern in
   read_image_frame().

2. backend/ffmpeg_tools.py — stitch_video() built the FFmpeg -i input
   path with string concatenation (in_dir + "/" + pattern), the only
   remaining hardcoded slash in the file. Replaced with os.path.join()
   for cross-platform consistency; os is already imported.

No logic changes. 221 tests pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nikopueringer nikopueringer merged commit 501ecb2 into nikopueringer:main Mar 14, 2026
3 checks passed
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.

2 participants