Skip to content

feat(action): add reusable clip/window abstraction for video understanding - #148

Open
ik020 wants to merge 4 commits into
grayhatdevelopers:mainfrom
ik020:feat/clip-level-video-understanding
Open

feat(action): add reusable clip/window abstraction for video understanding#148
ik020 wants to merge 4 commits into
grayhatdevelopers:mainfrom
ik020:feat/clip-level-video-understanding

Conversation

@ik020

@ik020 ik020 commented Sep 5, 2026

Copy link
Copy Markdown

Summary

Closes #83

This PR introduces a reusable clip/window abstraction for video understanding and adds shot-based clip generation to the VideoPrism action capability.

Changes

  • Added VideoClip and ClipStreamAccumulator abstractions for reusable video clip/window handling.
  • Added support for two VideoPrism clip modes:
    • fixed — existing fixed-size window behavior (default)
    • scene — shot-based windows using PySceneDetect
  • Wired shot-boundary detection into the VideoPrism indexing pipeline.
  • Ensured clips are flushed correctly at shot boundaries.
  • Preserved model-input padding without affecting stored clip metadata.
  • Added validation so clip_mode only accepts fixed or scene.
  • Added tests covering scene-boundary flushing and clip metadata.
  • Added a standalone benchmark comparing fixed and scene clip modes.

Validation

  • tests/test_videoprism.py5 passed
  • tests/test_capabilities.py17 passed, 2 subtests passed
  • Python syntax compilation — passed
  • git diff --checkpassed

Benchmark

Using a synthetic 9-second video containing 3 shots:

Mode Time Peak Memory Clips
fixed 0.093s 12.22 MB 2
scene 0.483s 9.28 MB 3

The benchmark mocks VideoPrism model inference and therefore measures clip/windowing and shot-detection overhead rather than end-to-end VideoPrism inference.

Notes

fixed remains the default mode, so existing behavior is preserved unless clip_mode="scene" is explicitly selected.

…rs#83

Extracts clip grouping into core/clip.py (VideoClip, ClipStreamAccumulator),
decoupling clip boundaries from the VideoPrism encoder. Fixed-window mode
preserves existing behavior exactly (verified by existing test suite).
…s#83

Adds core/scene_boundaries.py (PySceneDetect wrapper) and threads
source through the shared VisualProcessor.prepare() so action's
indexer can detect real shot boundaries when clip_mode='scene'.
Default clip_mode='fixed' behavior is unchanged.
Verifies prepare() calls detect_shot_boundaries and passes them into
ClipStreamAccumulator, and that process/finalize produce clips whose
start/end/sample_count respect the shot boundaries rather than fixed
16-frame windows.
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.

Add clip-level video understanding for actions and changes

1 participant