videoctx 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- videoctx-0.1.0/.github/workflows/ci.yml +34 -0
- videoctx-0.1.0/.gitignore +11 -0
- videoctx-0.1.0/LICENSE +202 -0
- videoctx-0.1.0/PKG-INFO +130 -0
- videoctx-0.1.0/README.md +110 -0
- videoctx-0.1.0/SPEC.md +91 -0
- videoctx-0.1.0/eval/finish_gemini.sh +25 -0
- videoctx-0.1.0/eval/methods.py +194 -0
- videoctx-0.1.0/eval/prep_indexes.py +40 -0
- videoctx-0.1.0/eval/prepare_videomme.py +83 -0
- videoctx-0.1.0/eval/results/finish_gemini.log +331 -0
- videoctx-0.1.0/eval/results/long_eval.log +162 -0
- videoctx-0.1.0/eval/results/long_naive.json +602 -0
- videoctx-0.1.0/eval/results/long_videoctx.json +602 -0
- videoctx-0.1.0/eval/results/long_videoctx_v2.json +602 -0
- videoctx-0.1.0/eval/results/long_videoctx_v3.json +632 -0
- videoctx-0.1.0/eval/results/pilot_short_claude.json +1142 -0
- videoctx-0.1.0/eval/results/pilot_short_gemini_partial.json +320 -0
- videoctx-0.1.0/eval/results/pilot_short_videoctx_v2.json +572 -0
- videoctx-0.1.0/eval/results/pilot_short_videoctx_v3.json +572 -0
- videoctx-0.1.0/eval/results/pilot_short_videoctx_v4.json +572 -0
- videoctx-0.1.0/eval/results/prep_long.log +39 -0
- videoctx-0.1.0/eval/results/short300.log +785 -0
- videoctx-0.1.0/eval/results/short300_dev_videoctx.json +2852 -0
- videoctx-0.1.0/eval/results/short300_test_naive.json +2852 -0
- videoctx-0.1.0/eval/results/short300_test_videoctx.json +2852 -0
- videoctx-0.1.0/eval/run.py +103 -0
- videoctx-0.1.0/eval/run_long_after_prep.sh +16 -0
- videoctx-0.1.0/eval/run_short300.sh +16 -0
- videoctx-0.1.0/eval/split_dev_test.py +23 -0
- videoctx-0.1.0/paper/draft.md +295 -0
- videoctx-0.1.0/pyproject.toml +34 -0
- videoctx-0.1.0/tests/smoke.py +39 -0
- videoctx-0.1.0/videoctx/__init__.py +1 -0
- videoctx-0.1.0/videoctx/captions.py +67 -0
- videoctx-0.1.0/videoctx/cli.py +70 -0
- videoctx-0.1.0/videoctx/frames.py +46 -0
- videoctx-0.1.0/videoctx/indexer.py +93 -0
- videoctx-0.1.0/videoctx/mcp_server.py +161 -0
- videoctx-0.1.0/videoctx/pricing.py +58 -0
- videoctx-0.1.0/videoctx/probe.py +35 -0
- videoctx-0.1.0/videoctx/query.py +271 -0
- videoctx-0.1.0/videoctx/schema.py +45 -0
- videoctx-0.1.0/videoctx/shots.py +54 -0
- videoctx-0.1.0/videoctx/textview.py +71 -0
- videoctx-0.1.0/videoctx/transcribe.py +42 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master, main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
smoke:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
- name: Install ffmpeg
|
|
14
|
+
run: sudo apt-get update && sudo apt-get install -y ffmpeg
|
|
15
|
+
- uses: astral-sh/setup-uv@v5
|
|
16
|
+
- name: Install package
|
|
17
|
+
run: uv venv && uv pip install -e .
|
|
18
|
+
- name: Generate test video (3 scenes, no audio)
|
|
19
|
+
run: |
|
|
20
|
+
mkdir -p samples
|
|
21
|
+
ffmpeg -v error -f lavfi -i testsrc2=duration=8:size=640x360:rate=30 -pix_fmt yuv420p s1.mp4
|
|
22
|
+
ffmpeg -v error -f lavfi -i mandelbrot=size=640x360:rate=30 -t 8 -pix_fmt yuv420p s2.mp4
|
|
23
|
+
ffmpeg -v error -f lavfi -i smptebars=duration=8:size=640x360:rate=30 -pix_fmt yuv420p s3.mp4
|
|
24
|
+
printf "file 's1.mp4'\nfile 's2.mp4'\nfile 's3.mp4'\n" > list.txt
|
|
25
|
+
ffmpeg -v error -f concat -safe 0 -i list.txt -c copy samples/ci.mp4
|
|
26
|
+
- name: Index it
|
|
27
|
+
run: .venv/bin/videoctx index samples/ci.mp4 --out indexes/ci.vctx
|
|
28
|
+
- name: Smoke test
|
|
29
|
+
run: .venv/bin/python tests/smoke.py indexes/ci.vctx
|
|
30
|
+
- name: MCP server starts
|
|
31
|
+
run: |
|
|
32
|
+
(.venv/bin/videoctx-mcp < /dev/null > /dev/null 2> mcp_err.txt &)
|
|
33
|
+
sleep 3
|
|
34
|
+
if grep -qiE "traceback" mcp_err.txt; then cat mcp_err.txt; exit 1; fi
|
videoctx-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
videoctx-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: videoctx
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Open, model-free video context layer for LLM agents: index once, query cheaply with any model.
|
|
5
|
+
Author: Fred Dunyo
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Python: >=3.11
|
|
9
|
+
Requires-Dist: anthropic>=0.60
|
|
10
|
+
Requires-Dist: click>=8.1
|
|
11
|
+
Requires-Dist: faster-whisper>=1.0
|
|
12
|
+
Requires-Dist: mcp>=2.0
|
|
13
|
+
Requires-Dist: pydantic>=2.7
|
|
14
|
+
Requires-Dist: scenedetect[opencv]>=0.6.4
|
|
15
|
+
Provides-Extra: eval
|
|
16
|
+
Requires-Dist: datasets>=2.19; extra == 'eval'
|
|
17
|
+
Requires-Dist: google-genai>=1.0; extra == 'eval'
|
|
18
|
+
Requires-Dist: pandas>=2.0; extra == 'eval'
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# videoctx
|
|
22
|
+
|
|
23
|
+
**Index a video once. Query it cheaply, forever, with any LLM.**
|
|
24
|
+
|
|
25
|
+
`videoctx` ("video context") turns any video into an open, portable **Video
|
|
26
|
+
Context** index (`.vctx`, see [SPEC.md](SPEC.md)) using only local, model-free
|
|
27
|
+
tools: ffmpeg keyframes, PySceneDetect shot boundaries, faster-whisper
|
|
28
|
+
transcripts, and optional one-line visual captions from any cheap VLM. An
|
|
29
|
+
agent answers most questions from the index's text layer for fractions of a
|
|
30
|
+
cent, and pulls individual frames on demand only when a question needs pixels.
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
videoctx index lecture.mp4 # one-time, local, free
|
|
34
|
+
videoctx show lecture.vctx # the text view the model reads
|
|
35
|
+
videoctx ask lecture.vctx "What diagram is shown when she explains backprop?"
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Why
|
|
39
|
+
|
|
40
|
+
Native video ingestion re-tokenizes the whole video on every question: an
|
|
41
|
+
hour of footage is ~250-350k tokens, every single time. Proprietary video
|
|
42
|
+
platforms index into closed representations behind per-minute pricing.
|
|
43
|
+
videoctx is the third option: an open on-disk format any model can consume,
|
|
44
|
+
produced by free tools, where the marginal cost of a follow-up question on an
|
|
45
|
+
hour-long video is about **$0.02**.
|
|
46
|
+
|
|
47
|
+
## Benchmark results (Video-MME, Oct 2026)
|
|
48
|
+
|
|
49
|
+
Full protocol and honest cost accounting (including prompt-cache write
|
|
50
|
+
premiums) in [paper/draft.md](paper/draft.md). Query model: Claude Opus 4.8.
|
|
51
|
+
|
|
52
|
+
**Short videos, held-out test half (n=150):**
|
|
53
|
+
|
|
54
|
+
| Method | Accuracy | $/question |
|
|
55
|
+
|---|---|---|
|
|
56
|
+
| **videoctx** | **83.3%** | **$0.0067** |
|
|
57
|
+
| Uniform frame sampling | 74.0% | $0.0172 |
|
|
58
|
+
|
|
59
|
+
**Identical 30-question subset, all methods:**
|
|
60
|
+
|
|
61
|
+
| Method | Accuracy | Latency/question |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| **videoctx** | **76.7%** | 2-20s |
|
|
64
|
+
| Uniform frame sampling | 60.0% | ~5s |
|
|
65
|
+
| Gemini Flash native ingestion | 53.3% | ~40s |
|
|
66
|
+
|
|
67
|
+
**Long videos, 30-60 minutes (n=30):**
|
|
68
|
+
|
|
69
|
+
| Method | Accuracy | $/question | Follow-up $/question |
|
|
70
|
+
|---|---|---|---|
|
|
71
|
+
| **videoctx** | **80.0%** | **$0.096** | **$0.024** |
|
|
72
|
+
| Uniform frame sampling (60-frame cap) | 70.0% | $0.133 | $0.133 |
|
|
73
|
+
| Native ingestion (published Pro rates, est.) | pending | ~$0.50 | ~$0.50 |
|
|
74
|
+
|
|
75
|
+
One-time index cost: ~$0.10 per hour of video (captions), pennies otherwise.
|
|
76
|
+
|
|
77
|
+
## Install
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
git clone <repo> && cd videoctx
|
|
81
|
+
uv venv && uv pip install -e .
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Requires `ffmpeg` on PATH. `videoctx index` and the MCP server's core tools
|
|
85
|
+
run fully locally with no API key. `videoctx ask` uses the Anthropic API
|
|
86
|
+
(`ANTHROPIC_API_KEY` or an `ant auth login` profile).
|
|
87
|
+
|
|
88
|
+
## MCP server: let any agent read videos
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
claude mcp add videoctx -- $(pwd)/.venv/bin/videoctx-mcp
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
The calling agent's own model reads the text layer and frames directly; the
|
|
95
|
+
server makes no model calls and needs no key. Tools: `video_overview` (cheap
|
|
96
|
+
text layer), `survey_video` (one thumbnail per shot), `get_frames(path, t0,
|
|
97
|
+
t1, detail)`, `transcript_search`, `index_video`. The server's instructions
|
|
98
|
+
carry the evidence rule: visual answers must cite fetched frames, never
|
|
99
|
+
general knowledge.
|
|
100
|
+
|
|
101
|
+
## Reproduce the benchmark
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
uv pip install -e ".[eval]"
|
|
105
|
+
python eval/prepare_videomme.py --duration short --videos 100 --out eval/data
|
|
106
|
+
python eval/split_dev_test.py eval/data/videomme_short.jsonl
|
|
107
|
+
python eval/run.py eval/data/videomme_short_test.jsonl --methods videoctx,naive
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
`eval/methods.py` documents each baseline. Cost accounting counts cache
|
|
111
|
+
writes at their real premium (1.25x / 2x by TTL); see the paper's Section 7.3
|
|
112
|
+
for the accounting traps this avoids.
|
|
113
|
+
|
|
114
|
+
## Format
|
|
115
|
+
|
|
116
|
+
The `.vctx` directory is plain JSON + JPEG: `manifest.json` (provenance,
|
|
117
|
+
parameters, source hash), `index.json` (shots, keyframes, transcript,
|
|
118
|
+
captions), `frames/`. Consumers must ignore unknown keys; enrichment layers
|
|
119
|
+
(OCR, embeddings) are reserved in [SPEC.md](SPEC.md) v0.1.
|
|
120
|
+
|
|
121
|
+
## Status and roadmap
|
|
122
|
+
|
|
123
|
+
Working and benchmarked: indexing, query loop, MCP server, eval harness.
|
|
124
|
+
Next: medium-duration subset, Pro-tier native baseline, cross-model
|
|
125
|
+
portability runs (same indexes via non-Claude models), OCR and per-shot
|
|
126
|
+
embedding layers, spec v1.0.
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
Apache-2.0. Copyright 2026 Fred Dunyo.
|
videoctx-0.1.0/README.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# videoctx
|
|
2
|
+
|
|
3
|
+
**Index a video once. Query it cheaply, forever, with any LLM.**
|
|
4
|
+
|
|
5
|
+
`videoctx` ("video context") turns any video into an open, portable **Video
|
|
6
|
+
Context** index (`.vctx`, see [SPEC.md](SPEC.md)) using only local, model-free
|
|
7
|
+
tools: ffmpeg keyframes, PySceneDetect shot boundaries, faster-whisper
|
|
8
|
+
transcripts, and optional one-line visual captions from any cheap VLM. An
|
|
9
|
+
agent answers most questions from the index's text layer for fractions of a
|
|
10
|
+
cent, and pulls individual frames on demand only when a question needs pixels.
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
videoctx index lecture.mp4 # one-time, local, free
|
|
14
|
+
videoctx show lecture.vctx # the text view the model reads
|
|
15
|
+
videoctx ask lecture.vctx "What diagram is shown when she explains backprop?"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Why
|
|
19
|
+
|
|
20
|
+
Native video ingestion re-tokenizes the whole video on every question: an
|
|
21
|
+
hour of footage is ~250-350k tokens, every single time. Proprietary video
|
|
22
|
+
platforms index into closed representations behind per-minute pricing.
|
|
23
|
+
videoctx is the third option: an open on-disk format any model can consume,
|
|
24
|
+
produced by free tools, where the marginal cost of a follow-up question on an
|
|
25
|
+
hour-long video is about **$0.02**.
|
|
26
|
+
|
|
27
|
+
## Benchmark results (Video-MME, Oct 2026)
|
|
28
|
+
|
|
29
|
+
Full protocol and honest cost accounting (including prompt-cache write
|
|
30
|
+
premiums) in [paper/draft.md](paper/draft.md). Query model: Claude Opus 4.8.
|
|
31
|
+
|
|
32
|
+
**Short videos, held-out test half (n=150):**
|
|
33
|
+
|
|
34
|
+
| Method | Accuracy | $/question |
|
|
35
|
+
|---|---|---|
|
|
36
|
+
| **videoctx** | **83.3%** | **$0.0067** |
|
|
37
|
+
| Uniform frame sampling | 74.0% | $0.0172 |
|
|
38
|
+
|
|
39
|
+
**Identical 30-question subset, all methods:**
|
|
40
|
+
|
|
41
|
+
| Method | Accuracy | Latency/question |
|
|
42
|
+
|---|---|---|
|
|
43
|
+
| **videoctx** | **76.7%** | 2-20s |
|
|
44
|
+
| Uniform frame sampling | 60.0% | ~5s |
|
|
45
|
+
| Gemini Flash native ingestion | 53.3% | ~40s |
|
|
46
|
+
|
|
47
|
+
**Long videos, 30-60 minutes (n=30):**
|
|
48
|
+
|
|
49
|
+
| Method | Accuracy | $/question | Follow-up $/question |
|
|
50
|
+
|---|---|---|---|
|
|
51
|
+
| **videoctx** | **80.0%** | **$0.096** | **$0.024** |
|
|
52
|
+
| Uniform frame sampling (60-frame cap) | 70.0% | $0.133 | $0.133 |
|
|
53
|
+
| Native ingestion (published Pro rates, est.) | pending | ~$0.50 | ~$0.50 |
|
|
54
|
+
|
|
55
|
+
One-time index cost: ~$0.10 per hour of video (captions), pennies otherwise.
|
|
56
|
+
|
|
57
|
+
## Install
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
git clone <repo> && cd videoctx
|
|
61
|
+
uv venv && uv pip install -e .
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Requires `ffmpeg` on PATH. `videoctx index` and the MCP server's core tools
|
|
65
|
+
run fully locally with no API key. `videoctx ask` uses the Anthropic API
|
|
66
|
+
(`ANTHROPIC_API_KEY` or an `ant auth login` profile).
|
|
67
|
+
|
|
68
|
+
## MCP server: let any agent read videos
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
claude mcp add videoctx -- $(pwd)/.venv/bin/videoctx-mcp
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The calling agent's own model reads the text layer and frames directly; the
|
|
75
|
+
server makes no model calls and needs no key. Tools: `video_overview` (cheap
|
|
76
|
+
text layer), `survey_video` (one thumbnail per shot), `get_frames(path, t0,
|
|
77
|
+
t1, detail)`, `transcript_search`, `index_video`. The server's instructions
|
|
78
|
+
carry the evidence rule: visual answers must cite fetched frames, never
|
|
79
|
+
general knowledge.
|
|
80
|
+
|
|
81
|
+
## Reproduce the benchmark
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
uv pip install -e ".[eval]"
|
|
85
|
+
python eval/prepare_videomme.py --duration short --videos 100 --out eval/data
|
|
86
|
+
python eval/split_dev_test.py eval/data/videomme_short.jsonl
|
|
87
|
+
python eval/run.py eval/data/videomme_short_test.jsonl --methods videoctx,naive
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`eval/methods.py` documents each baseline. Cost accounting counts cache
|
|
91
|
+
writes at their real premium (1.25x / 2x by TTL); see the paper's Section 7.3
|
|
92
|
+
for the accounting traps this avoids.
|
|
93
|
+
|
|
94
|
+
## Format
|
|
95
|
+
|
|
96
|
+
The `.vctx` directory is plain JSON + JPEG: `manifest.json` (provenance,
|
|
97
|
+
parameters, source hash), `index.json` (shots, keyframes, transcript,
|
|
98
|
+
captions), `frames/`. Consumers must ignore unknown keys; enrichment layers
|
|
99
|
+
(OCR, embeddings) are reserved in [SPEC.md](SPEC.md) v0.1.
|
|
100
|
+
|
|
101
|
+
## Status and roadmap
|
|
102
|
+
|
|
103
|
+
Working and benchmarked: indexing, query loop, MCP server, eval harness.
|
|
104
|
+
Next: medium-duration subset, Pro-tier native baseline, cross-model
|
|
105
|
+
portability runs (same indexes via non-Claude models), OCR and per-shot
|
|
106
|
+
embedding layers, spec v1.0.
|
|
107
|
+
|
|
108
|
+
## License
|
|
109
|
+
|
|
110
|
+
Apache-2.0. Copyright 2026 Fred Dunyo.
|
videoctx-0.1.0/SPEC.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Video Context Format: Spec v0.1 (draft)
|
|
2
|
+
|
|
3
|
+
Status: draft. Everything here may change until v1.0.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
A portable, model-free representation of a video, designed for LLM agents under
|
|
8
|
+
token budgets. A video is indexed **once** (locally, with open tools) into a
|
|
9
|
+
Video Context directory. Any model can then answer questions about the video by
|
|
10
|
+
reading the cheap text layer first and pulling individual frames only when
|
|
11
|
+
needed.
|
|
12
|
+
|
|
13
|
+
Design principles:
|
|
14
|
+
|
|
15
|
+
1. **Model-free.** Producing an index requires no proprietary model. ffmpeg,
|
|
16
|
+
scene detection, and open speech-to-text are sufficient. Optional layers
|
|
17
|
+
(captions, embeddings) may use any model the producer chooses, and the index
|
|
18
|
+
records which one.
|
|
19
|
+
2. **Text-first, frames-on-demand.** The text layer (structure + transcript +
|
|
20
|
+
captions) should answer most questions alone. Frames are addressable by
|
|
21
|
+
timestamp so a consumer fetches only what a question requires.
|
|
22
|
+
3. **Portable.** An index is a plain directory of JSON and JPEG. No database,
|
|
23
|
+
no server, no SDK required to consume it.
|
|
24
|
+
4. **Honest provenance.** The index records tool versions, parameters, and any
|
|
25
|
+
model calls used to produce it, so results are reproducible and costs
|
|
26
|
+
attributable.
|
|
27
|
+
|
|
28
|
+
## Directory layout
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
<name>.vctx/
|
|
32
|
+
manifest.json # format version, provenance, indexing parameters
|
|
33
|
+
index.json # the context document: shots, keyframes, transcript, captions
|
|
34
|
+
frames/ # extracted keyframes, JPEG
|
|
35
|
+
shot0003_t142.50.jpg
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## manifest.json
|
|
39
|
+
|
|
40
|
+
| field | type | notes |
|
|
41
|
+
|---|---|---|
|
|
42
|
+
| `format` | string | `"vctx"` |
|
|
43
|
+
| `format_version` | string | `"0.1"` |
|
|
44
|
+
| `created_at` | string | ISO 8601 |
|
|
45
|
+
| `producer` | object | `{name, version}` of the indexing tool |
|
|
46
|
+
| `params` | object | indexing parameters (detector, thresholds, whisper model, frame max edge, etc.) |
|
|
47
|
+
| `source` | object | `{filename, sha256, size_bytes}` of the source video |
|
|
48
|
+
|
|
49
|
+
## index.json
|
|
50
|
+
|
|
51
|
+
### `video`
|
|
52
|
+
|
|
53
|
+
`{duration_s, width, height, fps, has_audio}`
|
|
54
|
+
|
|
55
|
+
### `shots[]`
|
|
56
|
+
|
|
57
|
+
Visually coherent segments, ordered, non-overlapping, covering the full
|
|
58
|
+
duration.
|
|
59
|
+
|
|
60
|
+
| field | type | notes |
|
|
61
|
+
|---|---|---|
|
|
62
|
+
| `id` | int | 0-based |
|
|
63
|
+
| `start_s`, `end_s` | float | seconds |
|
|
64
|
+
| `keyframes[]` | array | `{t_s, file, width, height}`: `file` relative to index root |
|
|
65
|
+
| `caption` | string? | optional, one-line visual description |
|
|
66
|
+
| `caption_model` | string? | model that produced `caption`, if any |
|
|
67
|
+
|
|
68
|
+
### `transcript`
|
|
69
|
+
|
|
70
|
+
`{language, model, segments: [{start_s, end_s, text}]}`: empty `segments` if
|
|
71
|
+
the video has no speech or no audio.
|
|
72
|
+
|
|
73
|
+
### Reserved for later versions
|
|
74
|
+
|
|
75
|
+
`embeddings` (per-shot visual/text vectors), `entities`, `ocr`. Consumers must
|
|
76
|
+
ignore unknown keys.
|
|
77
|
+
|
|
78
|
+
## Consumer contract
|
|
79
|
+
|
|
80
|
+
A consumer (agent harness, MCP server, eval script) should expose three
|
|
81
|
+
operations over an index:
|
|
82
|
+
|
|
83
|
+
1. `text_view()` → compact plain-text rendering of shots + transcript, suitable
|
|
84
|
+
for direct inclusion in a prompt. This is the cheap path.
|
|
85
|
+
2. `get_frames(start_s, end_s, max_frames)` → the keyframes within a time
|
|
86
|
+
range, for when the question needs eyes.
|
|
87
|
+
3. `frame_at(t_s)` → nearest keyframe to a timestamp.
|
|
88
|
+
|
|
89
|
+
The intended agent loop: answer from `text_view()` if possible; otherwise call
|
|
90
|
+
`get_frames` on the narrowest relevant span; escalate density only if still
|
|
91
|
+
uncertain.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Gemini free-tier quota frees up on a ROLLING 24h window (not a daily reset),
|
|
3
|
+
# so drip-complete: sweep the remaining errored questions every 45 min; each
|
|
4
|
+
# sweep fills however many request slots have freed. Converges within ~12h.
|
|
5
|
+
set -e
|
|
6
|
+
cd "$(dirname "$0")/.."
|
|
7
|
+
set -a; . ./.env; set +a
|
|
8
|
+
PY=.venv/bin/python
|
|
9
|
+
OUT=eval/results/pilot_short_gemini_partial.json
|
|
10
|
+
|
|
11
|
+
done_count() {
|
|
12
|
+
$PY -c "import json; print(sum('error' not in r for r in json.load(open('$OUT'))))"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
while :; do
|
|
16
|
+
n_ok=$(done_count)
|
|
17
|
+
if [ "$n_ok" -ge 30 ]; then break; fi
|
|
18
|
+
echo "sweep: $n_ok/30 complete"
|
|
19
|
+
$PY eval/run.py eval/data/videomme_short_pilot30.jsonl --methods gemini \
|
|
20
|
+
--out "$OUT" --skip-existing || true
|
|
21
|
+
n_ok=$(done_count)
|
|
22
|
+
[ "$n_ok" -ge 30 ] && break
|
|
23
|
+
sleep 10800
|
|
24
|
+
done
|
|
25
|
+
echo "GEMINI SHORT FINAL"
|