@larkup/tool-video-intelligence 0.2.10 → 0.3.0
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.
- package/.env.example +3 -0
- package/README.md +11 -6
- package/dist/agent.d.ts +50 -0
- package/dist/agent.js +505 -241
- package/dist/contracts.d.ts +57 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -4
- package/package.json +3 -3
- package/runtime/app/config.py +1 -1
- package/runtime/app/main.py +0 -4
- package/runtime/app/services/brain.py +694 -71
- package/runtime/app/services/embedding.py +1 -1
- package/runtime/app/services/pipeline.py +256 -11
- package/runtime/app/services/vision.py +191 -34
- package/runtime/app/utils/timing.py +82 -2
- package/tool.manifest.json +1 -1
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import Any
|
|
3
|
+
from typing import Any, Iterable
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
FULL_SOURCE_VISUAL_SAMPLE_BUDGET = {
|
|
7
|
+
"fast": 240,
|
|
8
|
+
"balanced": 480,
|
|
9
|
+
"thorough": 720,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
FULL_SOURCE_OCR_SAMPLE_BUDGET = {
|
|
13
|
+
"fast": 90,
|
|
14
|
+
"balanced": 180,
|
|
15
|
+
"thorough": 300,
|
|
16
|
+
}
|
|
4
17
|
|
|
5
18
|
|
|
6
19
|
def normalized_important_ranges(
|
|
@@ -33,6 +46,48 @@ def visual_sampling_interval(mode: str, duration_seconds: float) -> float:
|
|
|
33
46
|
return max(base_intervals[mode], duration_seconds / max_samples[mode])
|
|
34
47
|
|
|
35
48
|
|
|
49
|
+
def bounded_visual_sampling_intervals(
|
|
50
|
+
mode: str,
|
|
51
|
+
covered_duration_secs: float,
|
|
52
|
+
sample_interval_secs: float,
|
|
53
|
+
priority_sample_interval_secs: float,
|
|
54
|
+
priority_ranges: Iterable[tuple[float, float]],
|
|
55
|
+
) -> tuple[float, float]:
|
|
56
|
+
"""Caps a full-source navigation pass while preserving priority detail.
|
|
57
|
+
|
|
58
|
+
A first index is a searchable map, not a substitute for the later bounded
|
|
59
|
+
close-read. The cap is expressed only in source duration and user-selected
|
|
60
|
+
mode, so it applies equally to every language and video subject.
|
|
61
|
+
"""
|
|
62
|
+
budget = FULL_SOURCE_VISUAL_SAMPLE_BUDGET.get(mode, FULL_SOURCE_VISUAL_SAMPLE_BUDGET["balanced"])
|
|
63
|
+
duration = max(0.001, float(covered_duration_secs))
|
|
64
|
+
priority_duration = sum(
|
|
65
|
+
max(0.0, min(duration, float(end)) - max(0.0, float(start)))
|
|
66
|
+
for start, end in priority_ranges
|
|
67
|
+
)
|
|
68
|
+
priority_budget = max(1, round(budget * 0.25)) if priority_duration > 0 else 0
|
|
69
|
+
base_budget = max(1, budget - priority_budget)
|
|
70
|
+
bounded_sample = max(float(sample_interval_secs), duration / base_budget)
|
|
71
|
+
bounded_priority = max(
|
|
72
|
+
float(priority_sample_interval_secs),
|
|
73
|
+
priority_duration / priority_budget if priority_budget else 0.0,
|
|
74
|
+
)
|
|
75
|
+
return bounded_sample, min(bounded_sample, bounded_priority)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def ocr_sampling_interval(
|
|
79
|
+
mode: str,
|
|
80
|
+
covered_duration_secs: float,
|
|
81
|
+
frame_sample_interval_secs: float,
|
|
82
|
+
) -> float:
|
|
83
|
+
"""Keeps OCR navigable without making every visual sample a text pass."""
|
|
84
|
+
budget = FULL_SOURCE_OCR_SAMPLE_BUDGET.get(mode, FULL_SOURCE_OCR_SAMPLE_BUDGET["balanced"])
|
|
85
|
+
return max(
|
|
86
|
+
float(frame_sample_interval_secs),
|
|
87
|
+
max(0.001, float(covered_duration_secs)) / budget,
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
|
|
36
91
|
def rebase_result_timestamps(result: dict[str, Any], offset_secs: float) -> None:
|
|
37
92
|
"""Translates clip-relative evidence (a bounded/rebased inspection) to the source clock."""
|
|
38
93
|
offset_ms = round(offset_secs * 1_000)
|
|
@@ -55,6 +110,25 @@ def rebase_result_timestamps(result: dict[str, Any], offset_secs: float) -> None
|
|
|
55
110
|
for track in result.get("tracks", []):
|
|
56
111
|
if isinstance(track, dict):
|
|
57
112
|
shift(track, "startMs", "endMs")
|
|
113
|
+
ledger = result.get("anonymousPresenceLedger")
|
|
114
|
+
if isinstance(ledger, dict):
|
|
115
|
+
for track in ledger.get("tracks", []):
|
|
116
|
+
if not isinstance(track, dict):
|
|
117
|
+
continue
|
|
118
|
+
shift(track, "startMs", "endMs")
|
|
119
|
+
if isinstance(track.get("timestampsMs"), list):
|
|
120
|
+
track["timestampsMs"] = [
|
|
121
|
+
round(float(timestamp)) + offset_ms
|
|
122
|
+
for timestamp in track["timestampsMs"]
|
|
123
|
+
if isinstance(timestamp, (int, float))
|
|
124
|
+
]
|
|
125
|
+
for label in ledger.get("labels", []):
|
|
126
|
+
if isinstance(label, dict) and isinstance(label.get("simultaneousTimestampsMs"), list):
|
|
127
|
+
label["simultaneousTimestampsMs"] = [
|
|
128
|
+
round(float(timestamp)) + offset_ms
|
|
129
|
+
for timestamp in label["simultaneousTimestampsMs"]
|
|
130
|
+
if isinstance(timestamp, (int, float))
|
|
131
|
+
]
|
|
58
132
|
for overlay in result.get("recurringOverlayText", []):
|
|
59
133
|
if not isinstance(overlay, dict):
|
|
60
134
|
continue
|
|
@@ -86,7 +160,7 @@ def rebase_result_timestamps(result: dict[str, Any], offset_secs: float) -> None
|
|
|
86
160
|
summary = result.get("knowledgeSummary")
|
|
87
161
|
if not isinstance(summary, dict):
|
|
88
162
|
return
|
|
89
|
-
for key in ("stateHistory", "keyEvents"):
|
|
163
|
+
for key in ("stateHistory", "keyEvents", "narrative"):
|
|
90
164
|
for item in summary.get(key, []):
|
|
91
165
|
if isinstance(item, dict):
|
|
92
166
|
shift(item, "startMs", "endMs")
|
|
@@ -97,3 +171,9 @@ def rebase_result_timestamps(result: dict[str, Any], offset_secs: float) -> None
|
|
|
97
171
|
for evidence in item.get("evidence", []):
|
|
98
172
|
if isinstance(evidence, dict):
|
|
99
173
|
shift(evidence, "startMs", "endMs")
|
|
174
|
+
for subject in summary.get("visibleSubjects", []):
|
|
175
|
+
if not isinstance(subject, dict):
|
|
176
|
+
continue
|
|
177
|
+
for appearance in subject.get("appearances", []):
|
|
178
|
+
if isinstance(appearance, dict):
|
|
179
|
+
shift(appearance, "startMs", "endMs")
|
package/tool.manifest.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"description": "Help your AI understand your videos, so you can ask questions and get answers from the right moments.",
|
|
8
8
|
"longDescription": "Turn videos into knowledge your AI can understand. It listens to what is said, reads what appears on screen, and helps you find the moments that matter.",
|
|
9
9
|
"category": "media",
|
|
10
|
-
"version": "0.
|
|
10
|
+
"version": "0.3.0",
|
|
11
11
|
"pricing": "free",
|
|
12
12
|
"emoji": "🎥",
|
|
13
13
|
"icon": "Film",
|