Skip to content

search_recording grabs thumbnails one at a time, then re-encodes them with a second ffmpeg #405

Backlog

Description

@TMHSDigital

Summary

Hit thumbnails are extracted serially, one ffmpeg per hit, and then passed through another ffmpeg to resize. With the default hit count that is a noticeable wait per query.

Where

  • src/tools/searchRecording.ts:86-99
  • src/utils/images.ts:51-62

Details

for (const [i, hit] of hits.slice(0, want).entries()) { ... await runFfmpeg(buildSampleAtTimestampArgs(source.path, at, out), 60_000, ...) }. That is one ffmpeg spawn and seek at a time, for up to MAX_INLINE_IMAGES (20) hits. encodeInlineImages then spawns another ffmpeg per PNG to scale it and convert it to JPEG. All other per-timestamp grabs use mapPool (#290: "each spawn costs ~200 ms before decoding").

Impact

images: 20 costs about 40 serial-ish spawns. That is several seconds that a pooled single pass would cut 2-4x. It matters only when thumbnails are requested (the default is 0).

Steps to reproduce

search_recording { input, query, images: 20 } on a long recording.

Suggested fix

Use mapPool for the grabs, and grab straight to a scaled JPEG (-vf scale=480:-2 -q:v 5 out.jpg) so the encodeInlineImages re-encode can be skipped, or pass width to the grab.

Acceptance criteria

  • Thumbnails are extracted with bounded concurrency and scaled in the same ffmpeg call

Getting started

  • Relevant files: src/tools/searchRecording.ts, src/utils/images.ts
  • Run tests: npm test (also npm run typecheck and npm run lint); see CONTRIBUTING.md
  • If you change a tool's schema or description, run npm run docs

Filed by repo-audit/full-audit at f0e5ebd. Severity: low. Effort: S. audit-key: performance|src/tools/searchRecording.ts|images

Activity

  1. added
    priority: low
    performance
    effort: small
    on Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort: smallperformancepriority: low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions