Skip to content

Warn once, not per video, when ffmpeg is missing - #412

Merged
lstein merged 3 commits into
masterfrom
lstein/fix/ffmpeg-warning-spam
Sep 29, 2026
Merged

lstein merged 3 commits into
masterfrom
lstein/fix/ffmpeg-warning-spam

Conversation

@lstein

@lstein lstein commented Sep 29, 2026

Copy link
Copy Markdown
Owner

Problem

When ffmpeg is missing, an index run logged the same warning for every video. With the Docker images shipping without ffmpeg (#410), that is now the default for every Docker user with videos. There were two sources:

  1. ffmpeg_exe() deliberately looks for ffmpeg again after every failure, so a temporary glitch doesn't switch off video for the whole process. It also logged a WARNING on every failed attempt.
  2. extract_video_frame() then fell through to its generic Could not extract a frame from …; skipping it. warning, so each video produced a second line.

Fix

  • One warning for the lookup: a new _report_missing() helper logs a WARNING only the first time ffmpeg is found missing, and later failures at DEBUG. It runs under the existing _ffmpeg_exe_lock, so parallel indexing workers still produce a single warning. What ffmpeg_exe() returns, and the look-again-every-time behaviour, are unchanged.
  • No per-video warning from frame extraction: extract_video_frame() now returns None quietly when ffmpeg is unavailable, instead of falling through to the per-video warning.

Users still get told why videos were skipped: the end-of-indexing message ("…skipped: PhotoMapAI could not find a working ffmpeg") and its WARNING still fire on every run. As a side effect, video-conversion polls no longer log a warning on each poll; they still return state="unavailable" with the explanation.

Tests

New tests in tests/backend/test_video_probe.py:

  • 50 failed lookups give exactly one warning, and each of the 50 still really looks for ffmpeg.
  • The "not executable" failure also warns once.
  • 8 concurrent workers give one warning.
  • Extracting frames from 5 videos with no ffmpeg logs exactly one warning in total.

Each test fails without its matching fix. pytest tests/backend -k "video or index or umap or media or embed": 598 passed. ruff check is clean.

An adversarial fresh-context review found the frame-extraction warning, which is fixed in the second commit. It also pointed out that a "re-arm after recovery" test described something that can't happen, since a found binary is remembered for the life of the process. That test and the matching docstring claim were removed.

🤖 Generated with Claude Code

lstein and others added 3 commits September 28, 2026 22:40
ffmpeg_exe() deliberately re-probes after a failure, so with no ffmpeg
at all every video in an index run logged the same warning. That is now
the default in the Docker images (#410). Warn only on the transition
into missing, log repeats at debug, and re-arm once a binary is found.
The check-and-flip runs under the existing probe lock, so concurrent
indexing workers still produce a single warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
extract_video_frame fell through to its generic per-video warning when
ffmpeg was unavailable, so the spam survived the probe dedup. Also drop
the re-arm claim: a found binary is memoized for the process lifetime.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lstein
lstein enabled auto-merge (squash) September 29, 2026 21:48
@lstein
lstein merged commit 0f6f6c0 into master Sep 29, 2026
10 checks passed
@lstein
lstein deleted the lstein/fix/ffmpeg-warning-spam branch September 29, 2026 22:03
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