Add optional TwelveLabs video segmentation backend (Marengo + Pegasus) - #13
Open
mohit-twelvelabs wants to merge 1 commit into
Open
Add optional TwelveLabs video segmentation backend (Marengo + Pegasus)#13mohit-twelvelabs wants to merge 1 commit into
mohit-twelvelabs wants to merge 1 commit into
Conversation
Add an opt-in segmentation backend that analyzes video frames and audio
directly via TwelveLabs (Marengo retrieval + Pegasus analysis), instead of
relying on Whisper transcripts. Useful for speech-light content. Returns the
same {start, end, summary, tags} structure so the existing clip/export flow is
unchanged. Enabled via SEGMENTER_TYPE=twelvelabs; default behavior unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi! I'm Mohit, I work at TwelveLabs (@mohit-twelvelabs).
What this adds
An opt-in segmentation backend that analyzes the video frames and audio directly via TwelveLabs, as an alternative to the default Whisper-transcript + LLM pipeline:
search) — semantic retrieval to locate clips relevant to the user's prompt.analyze) — generates the per-segment summary and tags.It returns the exact same
{start, end, summary, tags}structure the rest of the app already consumes, so the analysis table, re-analyze tab, clipping, and export flows all work unchanged.Why it helps PreenCut
The current pipeline keys off speech (Whisper → transcript → LLM). For speech-light footage — sports, b-roll, surveillance, music videos, silent demos — there's little transcript to segment on. Segmenting straight from the visual + audio content covers that gap.
Opt-in / non-breaking
Disabled by default. The default
SEGMENTER_TYPE=llmpath is untouched. To enable:New config lives alongside the existing
LLM_MODEL_OPTIONSinconfig.py; the processor (modules/twelvelabs_processor.py) mirrorsLLMProcessor.segment_video's contract and is swapped inprocessing_queue.pyonly when opted in.twelvelabs>=1.2.8added torequirements.txt.How it was tested
tests/test_twelvelabs_processor.py), runnable as plain Python or via pytest.TWELVELABS_API_KEY, skipped when unset) confirming a Marengo text embedding returns a vector.analyzereturns well-formed{start, end, summary, tags}segments and Marengosearchreturns relevant time windows that the overlap filter applies correctly. The slow upload/index step uses the documented SDK signatures (tasks.create/wait_for_done).You can grab a free API key at https://twelvelabs.io — there's a generous free tier.