vidlens 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.
Binary file
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "video-analyzer",
3
+ "owner": {
4
+ "name": "Mahantesh"
5
+ },
6
+ "metadata": {
7
+ "description": "Let Claude watch short videos from a link: Instagram Reels, YouTube Shorts, X and TikTok."
8
+ },
9
+ "plugins": [
10
+ {
11
+ "name": "video-analyzer",
12
+ "source": "./",
13
+ "description": "Analyze Instagram Reels, YouTube Shorts, X and TikTok videos from a link."
14
+ }
15
+ ]
16
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "video-analyzer",
3
+ "version": "0.1.0",
4
+ "description": "Let Claude watch short videos from a link: Instagram Reels, YouTube Shorts, X and TikTok. Local transcription (Whisper) plus keyframes; no API keys, nothing leaves your machine except the download.",
5
+ "author": {
6
+ "name": "Mahantesh"
7
+ },
8
+ "license": "MIT",
9
+ "keywords": [
10
+ "instagram",
11
+ "reels",
12
+ "youtube",
13
+ "shorts",
14
+ "video",
15
+ "transcript",
16
+ "mcp"
17
+ ],
18
+ "mcpServers": {
19
+ "video-analyzer": {
20
+ "command": "uv",
21
+ "args": [
22
+ "run",
23
+ "--directory",
24
+ "${CLAUDE_PLUGIN_ROOT}",
25
+ "video-analyzer-mcp"
26
+ ]
27
+ }
28
+ }
29
+ }
@@ -0,0 +1,8 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ .pytest_cache/
5
+ dist/
6
+ *.egg-info/
7
+ .DS_Store
8
+ .claude/settings.local.json
@@ -0,0 +1,77 @@
1
+ # video-analyzer — context for Claude Code
2
+
3
+ ## What this is
4
+ Free, open-source (MIT) local tool that lets Claude "watch" short videos from a link
5
+ (Instagram Reels first; also YouTube Shorts, X, TikTok via yt-dlp). Packaged three ways:
6
+ 1. Core Python package + CLI (`video-analyzer <url>`) in `src/video_analyzer/`
7
+ 2. MCP server (`video-analyzer-mcp`, stdio) with tools `analyze_video` and `get_transcript`
8
+ 3. Claude plugin: `.claude-plugin/plugin.json` (MCP server declared inline there), `.claude-plugin/marketplace.json`,
9
+ `skills/video-analysis/SKILL.md`, `commands/analyze-reel.md`
10
+
11
+ Key design decision: the server does NO LLM calls. It returns metadata, caption, timestamped
12
+ Whisper transcript and keyframe images; Claude does the analysis and reads on-screen text.
13
+ Zero running cost; users run analysis on their own Claude plan.
14
+
15
+ Positioning: free local tool first. A paid hosted/freemium version only later, if adoption
16
+ justifies it (would need server-side downloads, auth, ToS risk review).
17
+
18
+ ## Pipeline
19
+ fetch.py (yt-dlp, 720p cap, optional browser cookies) → media.py (ffprobe, scene-cut detection
20
+ via ffmpeg `select=gt(scene,0.3)`, pick_times: hook at 0.5s + cuts, thinned/topped up to
21
+ max_frames, 512px JPEGs) → transcribe.py (faster-whisper, CPU int8, VAD on, drops
22
+ no_speech_prob > 0.6) → pipeline.py (cache at ~/.cache/video-analyzer/<sha1>/result.json,
23
+ deletes video+wav unless --keep-media; transcription failure keeps frames).
24
+
25
+ Stdout is the MCP protocol channel: never print to stdout in library code (use stderr).
26
+ Uses mcp SDK 2.x: `from mcp.server.mcpserver import MCPServer, Image` (FastMCP was renamed);
27
+ CallToolResult fields are snake_case (`is_error`, `mime_type`).
28
+
29
+ ## Status (2026-12-06)
30
+ - Built in a sandbox with no access to Instagram/YouTube/Hugging Face.
31
+ - 10 unit tests pass on generated sample videos (`uv run pytest`); Whisper is mocked there.
32
+ - MCP stdio smoke test passed on a local file (`scripts/smoke_mcp.py`).
33
+ - NOT yet tested: real downloads from Instagram/YouTube/X, real Whisper transcription,
34
+ install as a plugin in Claude Code / Claude Desktop.
35
+ - Mac setup done (uv sync, 11 tests pass). Real YouTube download + real Whisper verified;
36
+ MCP stdio smoke test passes on a real URL.
37
+ - Fixed: faster-whisper 1.2.1's PyAV decoder breaks on av 19 (`metadata_errors`), so
38
+ transcribe.py now loads the 16 kHz WAV itself (`load_wav`) and passes a numpy array.
39
+ - Instagram Reel download works without cookies (tested on a 100s Hinglish talking-head Reel).
40
+ - Default Whisper model is now large-v3-turbo: 30s vs 61s for "small" on that Reel, and
41
+ readable (it outputs English for Hinglish; small gave garbled Devanagari).
42
+ - Keyframes: default count scales with length (media.auto_frames: ~1 per second or 1 per scene, 8-20); frames are
43
+ spread in equal time slots, snapped 0.8s after a scene cut (threshold 0.15), plus the ending.
44
+ Old 0.3 threshold + 8 frames caught 1 of ~15 overlays on that Reel; now most of them.
45
+ - If all scenes fit (<=20), auto mode takes one frame per scene: a 19s music-only Short with
46
+ 9 text cards now gets 9/9 (was 7/9 with dupes). Music-only gives empty transcript, no
47
+ hallucinated lyrics.
48
+ - X video (19s scrolling screen recording, no scene cuts) works; needed ~1 frame/s to catch
49
+ its cards, hence the denser default. Whisper said "Bye." on its music: transcripts made
50
+ only of stock hallucinations are now dropped (transcribe.drop_hallucinations).
51
+ - Installed as a plugin in the user's Claude Code (user scope, marketplace = this folder);
52
+ verified from a fresh `claude -p` session. The root `.mcp.json` was removed: Claude Code
53
+ also read it as project MCP config when opened in this folder and failed on
54
+ ${CLAUDE_PLUGIN_ROOT}.
55
+ - list_videos (MCP tool + `--list N [--popular]` CLI): YouTube channel (bare link -> /shorts),
56
+ playlists, TikTok profiles work. Instagram profiles: yt-dlp extractor broken; X profiles:
57
+ unsupported. Both give a clear "paste the links" error.
58
+ - Possible later: detect gradual content change (scrolls) instead of only hard cuts; a naive
59
+ pixel-diff detector was too noisy on camera motion.
60
+ - Not a git repo yet.
61
+
62
+ ## Next steps
63
+ 1. `rm -rf .venv && uv sync --group dev && uv run pytest`
64
+ 2. End-to-end on real links: a talking-head Reel, a music-only Reel with text overlays,
65
+ a non-English Reel, a YouTube Short, an X video. Check transcript quality, keyframe choice
66
+ (do the frames capture every overlay text change?), timing, and error messages.
67
+ 3. Tune: scene threshold / max_frames defaults; consider using YouTube's own captions when
68
+ available to skip Whisper; consider handling Instagram carousel posts (multiple videos).
69
+ 4. Test as a plugin: `/plugin marketplace add <this folder>` then
70
+ `/plugin install video-analyzer@video-analyzer`; and via Claude Desktop config (README).
71
+ 5. `git init`, first commit, push to GitHub; add a CI workflow running pytest (needs ffmpeg).
72
+ 6. Polish README with a demo GIF/example output before announcing.
73
+
74
+ ## Conventions
75
+ - `uv` for everything; Python >= 3.10.
76
+ - Keep the tool dependency-light and one-command to install; setup friction kills free tools.
77
+ - Config only via VIDEO_ANALYZER_* env vars (see config.py / README).
vidlens-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mahantesh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
vidlens-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,143 @@
1
+ Metadata-Version: 2.5
2
+ Name: vidlens
3
+ Version: 0.1.0
4
+ Summary: Turn Instagram Reels, YouTube Shorts and X videos into transcripts, keyframes and metadata that Claude can analyze.
5
+ Project-URL: Homepage, https://github.com/Mahanteshambi/video-analyzer
6
+ Project-URL: Issues, https://github.com/Mahanteshambi/video-analyzer/issues
7
+ Author: Mahantesh Ambi
8
+ License: MIT
9
+ License-File: LICENSE
10
+ Keywords: claude,instagram,mcp,reels,tiktok,video-analysis,whisper,youtube-shorts
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: MacOS
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Multimedia :: Video
16
+ Requires-Python: >=3.10
17
+ Requires-Dist: faster-whisper>=1.1.0
18
+ Requires-Dist: mcp<3,>=2.0
19
+ Requires-Dist: yt-dlp>=2025.1.1
20
+ Description-Content-Type: text/markdown
21
+
22
+ # video-analyzer
23
+
24
+ [![tests](https://github.com/Mahanteshambi/video-analyzer/actions/workflows/ci.yml/badge.svg)](https://github.com/Mahanteshambi/video-analyzer/actions/workflows/ci.yml)
25
+ [![PyPI](https://img.shields.io/pypi/v/vidlens)](https://pypi.org/project/vidlens/)
26
+
27
+ Let Claude **watch** short videos from a link: Instagram Reels, YouTube Shorts, X and TikTok
28
+ (anything [yt-dlp](https://github.com/yt-dlp/yt-dlp) supports). Free, local, no API keys.
29
+
30
+ <!-- mcp-name: io.github.Mahanteshambi/video-analyzer -->
31
+
32
+ ![demo](https://raw.githubusercontent.com/Mahanteshambi/video-analyzer/main/docs/demo.gif)
33
+
34
+ Paste a link into Claude and ask anything: *"summarise this Reel"*, *"why does the hook work?"*,
35
+ *"fact-check her stock claim"*, *"what do this channel's 10 most-viewed Shorts have in common?"*
36
+
37
+ ## How it works
38
+
39
+ ```
40
+ link ─► yt-dlp download ─► ffmpeg ─┬─► audio ─► Whisper (local) ─► timestamped transcript
41
+ └─► keyframes spread over the video, snapped to scene cuts (first = hook, last = ending)
42
+ │
43
+ caption + views/likes + transcript + keyframe images ─► Claude analyses
44
+ ```
45
+
46
+ - **Runs on your machine.** Transcription is local (faster-whisper); no API keys, no server.
47
+ - **Claude does the thinking.** The tool returns raw material; Claude reads the transcript *and*
48
+ looks at the keyframes, so music-only Reels with text overlays work too.
49
+ - **Whole channels.** List a YouTube channel's or TikTok profile's videos (by views) and compare them.
50
+ - **Cached.** The same link isn't processed twice.
51
+
52
+ ### Example
53
+
54
+ From the [demo video](docs/demo-reel.mp4) (a 15s Reel with text cards and a voice-over), the tool
55
+ returns a transcript plus these keyframes, one per text card:
56
+
57
+ ![keyframes](https://raw.githubusercontent.com/Mahanteshambi/video-analyzer/main/docs/keyframes.jpg)
58
+
59
+ Claude then answers from both, e.g.:
60
+
61
+ > **Gist:** a productivity listicle: "3 habits that save 2 hours a day".
62
+ > **Hook (0–3s):** the promise "save 2 hours a day" spoken and on screen at once.
63
+ > **Structure:** hook → 3 numbered tips (email twice a day, 2-minute rule, plan tomorrow tonight) → "Follow for more" CTA, about 3s per card.
64
+
65
+ ## Install
66
+
67
+ You need [uv](https://docs.astral.sh/uv/) and ffmpeg. On macOS: `brew install uv ffmpeg`
68
+ (Linux: your package manager's `ffmpeg`, plus uv). The first run downloads the Whisper speech model (about 1.6 GB).
69
+
70
+ ### Claude Code (plugin)
71
+
72
+ ```
73
+ /plugin marketplace add Mahanteshambi/video-analyzer
74
+ /plugin install video-analyzer@video-analyzer
75
+ ```
76
+
77
+ Start a new session, then paste a link, or run `/video-analyzer:analyze-reel <url> hook`.
78
+
79
+ ### Claude Desktop (or any MCP client)
80
+
81
+ Add this to `~/Library/Application Support/Claude/claude_desktop_config.json` and restart Claude
82
+ (use the full path from `which uvx`; desktop apps don't see your shell PATH):
83
+
84
+ ```json
85
+ {
86
+ "mcpServers": {
87
+ "video-analyzer": {
88
+ "command": "/opt/homebrew/bin/uvx",
89
+ "args": ["--from", "vidlens", "video-analyzer-mcp"]
90
+ }
91
+ }
92
+ }
93
+ ```
94
+
95
+ ### Terminal
96
+
97
+ ```bash
98
+ uvx --from vidlens video-analyzer "https://www.instagram.com/reel/XXXXXXXXX/"
99
+ uvx --from vidlens video-analyzer "https://www.youtube.com/@somechannel" --list 10 --popular
100
+ ```
101
+
102
+ ## Tools
103
+
104
+ | Tool | Returns |
105
+ |---|---|
106
+ | `analyze_video(url, max_frames=None, refresh=False)` | metadata, caption, timestamped transcript, keyframe images |
107
+ | `get_transcript(url)` | metadata, caption and transcript as JSON (no images, cheaper) |
108
+ | `list_videos(url, limit=10, sort="recent")` | a YouTube channel's Shorts (or playlist, TikTok profile) with views; `sort="popular"` for most viewed. Not Instagram/X profiles |
109
+
110
+ ## Settings (environment variables)
111
+
112
+ | Variable | Default | Purpose |
113
+ |---|---|---|
114
+ | `VIDEO_ANALYZER_WHISPER_MODEL` | `large-v3-turbo` | `small` = 480 MB download but slower and much worse on mixed-language speech; `tiny`/`base` = smallest |
115
+ | `VIDEO_ANALYZER_COOKIES_BROWSER` | unset | `chrome`, `safari` or `firefox`: use your logged-in session when a site asks for login or rate-limits |
116
+ | `VIDEO_ANALYZER_CACHE` | `~/.cache/video-analyzer` | where results and keyframes are stored |
117
+ | `VIDEO_ANALYZER_MAX_DURATION` | `900` | refuse videos longer than this (seconds) |
118
+
119
+ For Claude Desktop, put these in an `"env": { ... }` block next to `"args"`.
120
+
121
+ ## Troubleshooting
122
+
123
+ - **Instagram says login required / rate-limited:** set `VIDEO_ANALYZER_COOKIES_BROWSER=chrome`
124
+ and be logged in to Instagram in that browser. Update yt-dlp often: `uv lock --upgrade-package yt-dlp && uv sync`.
125
+ - **`ffmpeg not found`:** `brew install ffmpeg`.
126
+ - **Transcript of a music-only video is empty:** expected. Claude uses the keyframes and caption.
127
+
128
+ ## Development
129
+
130
+ ```bash
131
+ git clone https://github.com/Mahanteshambi/video-analyzer && cd video-analyzer
132
+ uv sync --group dev
133
+ uv run pytest # unit tests on generated sample videos
134
+ uv run python scripts/smoke_mcp.py <url-or-file> # end-to-end through the MCP protocol
135
+ ```
136
+
137
+ ## Responsible use
138
+
139
+ This tool downloads publicly accessible videos for personal analysis, on your machine, with your
140
+ connection. Platforms' terms of service (including Instagram's) restrict automated access. You
141
+ are responsible for how you use it. Respect creators' copyright; don't republish their content. For personal use.
142
+
143
+ MIT licensed.
@@ -0,0 +1,122 @@
1
+ # video-analyzer
2
+
3
+ [![tests](https://github.com/Mahanteshambi/video-analyzer/actions/workflows/ci.yml/badge.svg)](https://github.com/Mahanteshambi/video-analyzer/actions/workflows/ci.yml)
4
+ [![PyPI](https://img.shields.io/pypi/v/vidlens)](https://pypi.org/project/vidlens/)
5
+
6
+ Let Claude **watch** short videos from a link: Instagram Reels, YouTube Shorts, X and TikTok
7
+ (anything [yt-dlp](https://github.com/yt-dlp/yt-dlp) supports). Free, local, no API keys.
8
+
9
+ <!-- mcp-name: io.github.Mahanteshambi/video-analyzer -->
10
+
11
+ ![demo](https://raw.githubusercontent.com/Mahanteshambi/video-analyzer/main/docs/demo.gif)
12
+
13
+ Paste a link into Claude and ask anything: *"summarise this Reel"*, *"why does the hook work?"*,
14
+ *"fact-check her stock claim"*, *"what do this channel's 10 most-viewed Shorts have in common?"*
15
+
16
+ ## How it works
17
+
18
+ ```
19
+ link ─► yt-dlp download ─► ffmpeg ─┬─► audio ─► Whisper (local) ─► timestamped transcript
20
+ └─► keyframes spread over the video, snapped to scene cuts (first = hook, last = ending)
21
+ │
22
+ caption + views/likes + transcript + keyframe images ─► Claude analyses
23
+ ```
24
+
25
+ - **Runs on your machine.** Transcription is local (faster-whisper); no API keys, no server.
26
+ - **Claude does the thinking.** The tool returns raw material; Claude reads the transcript *and*
27
+ looks at the keyframes, so music-only Reels with text overlays work too.
28
+ - **Whole channels.** List a YouTube channel's or TikTok profile's videos (by views) and compare them.
29
+ - **Cached.** The same link isn't processed twice.
30
+
31
+ ### Example
32
+
33
+ From the [demo video](docs/demo-reel.mp4) (a 15s Reel with text cards and a voice-over), the tool
34
+ returns a transcript plus these keyframes, one per text card:
35
+
36
+ ![keyframes](https://raw.githubusercontent.com/Mahanteshambi/video-analyzer/main/docs/keyframes.jpg)
37
+
38
+ Claude then answers from both, e.g.:
39
+
40
+ > **Gist:** a productivity listicle: "3 habits that save 2 hours a day".
41
+ > **Hook (0–3s):** the promise "save 2 hours a day" spoken and on screen at once.
42
+ > **Structure:** hook → 3 numbered tips (email twice a day, 2-minute rule, plan tomorrow tonight) → "Follow for more" CTA, about 3s per card.
43
+
44
+ ## Install
45
+
46
+ You need [uv](https://docs.astral.sh/uv/) and ffmpeg. On macOS: `brew install uv ffmpeg`
47
+ (Linux: your package manager's `ffmpeg`, plus uv). The first run downloads the Whisper speech model (about 1.6 GB).
48
+
49
+ ### Claude Code (plugin)
50
+
51
+ ```
52
+ /plugin marketplace add Mahanteshambi/video-analyzer
53
+ /plugin install video-analyzer@video-analyzer
54
+ ```
55
+
56
+ Start a new session, then paste a link, or run `/video-analyzer:analyze-reel <url> hook`.
57
+
58
+ ### Claude Desktop (or any MCP client)
59
+
60
+ Add this to `~/Library/Application Support/Claude/claude_desktop_config.json` and restart Claude
61
+ (use the full path from `which uvx`; desktop apps don't see your shell PATH):
62
+
63
+ ```json
64
+ {
65
+ "mcpServers": {
66
+ "video-analyzer": {
67
+ "command": "/opt/homebrew/bin/uvx",
68
+ "args": ["--from", "vidlens", "video-analyzer-mcp"]
69
+ }
70
+ }
71
+ }
72
+ ```
73
+
74
+ ### Terminal
75
+
76
+ ```bash
77
+ uvx --from vidlens video-analyzer "https://www.instagram.com/reel/XXXXXXXXX/"
78
+ uvx --from vidlens video-analyzer "https://www.youtube.com/@somechannel" --list 10 --popular
79
+ ```
80
+
81
+ ## Tools
82
+
83
+ | Tool | Returns |
84
+ |---|---|
85
+ | `analyze_video(url, max_frames=None, refresh=False)` | metadata, caption, timestamped transcript, keyframe images |
86
+ | `get_transcript(url)` | metadata, caption and transcript as JSON (no images, cheaper) |
87
+ | `list_videos(url, limit=10, sort="recent")` | a YouTube channel's Shorts (or playlist, TikTok profile) with views; `sort="popular"` for most viewed. Not Instagram/X profiles |
88
+
89
+ ## Settings (environment variables)
90
+
91
+ | Variable | Default | Purpose |
92
+ |---|---|---|
93
+ | `VIDEO_ANALYZER_WHISPER_MODEL` | `large-v3-turbo` | `small` = 480 MB download but slower and much worse on mixed-language speech; `tiny`/`base` = smallest |
94
+ | `VIDEO_ANALYZER_COOKIES_BROWSER` | unset | `chrome`, `safari` or `firefox`: use your logged-in session when a site asks for login or rate-limits |
95
+ | `VIDEO_ANALYZER_CACHE` | `~/.cache/video-analyzer` | where results and keyframes are stored |
96
+ | `VIDEO_ANALYZER_MAX_DURATION` | `900` | refuse videos longer than this (seconds) |
97
+
98
+ For Claude Desktop, put these in an `"env": { ... }` block next to `"args"`.
99
+
100
+ ## Troubleshooting
101
+
102
+ - **Instagram says login required / rate-limited:** set `VIDEO_ANALYZER_COOKIES_BROWSER=chrome`
103
+ and be logged in to Instagram in that browser. Update yt-dlp often: `uv lock --upgrade-package yt-dlp && uv sync`.
104
+ - **`ffmpeg not found`:** `brew install ffmpeg`.
105
+ - **Transcript of a music-only video is empty:** expected. Claude uses the keyframes and caption.
106
+
107
+ ## Development
108
+
109
+ ```bash
110
+ git clone https://github.com/Mahanteshambi/video-analyzer && cd video-analyzer
111
+ uv sync --group dev
112
+ uv run pytest # unit tests on generated sample videos
113
+ uv run python scripts/smoke_mcp.py <url-or-file> # end-to-end through the MCP protocol
114
+ ```
115
+
116
+ ## Responsible use
117
+
118
+ This tool downloads publicly accessible videos for personal analysis, on your machine, with your
119
+ connection. Platforms' terms of service (including Instagram's) restrict automated access. You
120
+ are responsible for how you use it. Respect creators' copyright; don't republish their content. For personal use.
121
+
122
+ MIT licensed.
@@ -0,0 +1,8 @@
1
+ ---
2
+ description: Analyze an Instagram Reel, YouTube Short, X or TikTok video from a link
3
+ argument-hint: <video-url> [what you want: summary | hook | fact-check | script]
4
+ ---
5
+
6
+ Use the video-analysis skill. Call `analyze_video` on the link in: $ARGUMENTS
7
+
8
+ If the user said what they want (summary, hook breakdown, fact-check, reusable script), focus on that; otherwise give the default analysis.
@@ -0,0 +1,42 @@
1
+ [project]
2
+ name = "vidlens"
3
+ version = "0.1.0"
4
+ description = "Turn Instagram Reels, YouTube Shorts and X videos into transcripts, keyframes and metadata that Claude can analyze."
5
+ readme = "README.md"
6
+ license = { text = "MIT" }
7
+ authors = [{ name = "Mahantesh Ambi" }]
8
+ keywords = ["instagram", "reels", "youtube-shorts", "tiktok", "whisper", "mcp", "claude", "video-analysis"]
9
+ classifiers = [
10
+ "License :: OSI Approved :: MIT License",
11
+ "Programming Language :: Python :: 3",
12
+ "Operating System :: MacOS",
13
+ "Operating System :: POSIX :: Linux",
14
+ "Topic :: Multimedia :: Video",
15
+ ]
16
+ requires-python = ">=3.10"
17
+ dependencies = [
18
+ "yt-dlp>=2025.1.1",
19
+ "faster-whisper>=1.1.0",
20
+ "mcp>=2.0,<3",
21
+ ]
22
+
23
+ [project.urls]
24
+ Homepage = "https://github.com/Mahanteshambi/video-analyzer"
25
+ Issues = "https://github.com/Mahanteshambi/video-analyzer/issues"
26
+
27
+ [project.scripts]
28
+ video-analyzer = "video_analyzer.cli:main"
29
+ video-analyzer-mcp = "video_analyzer.server:main"
30
+
31
+ [dependency-groups]
32
+ dev = ["pytest>=8"]
33
+
34
+ [build-system]
35
+ requires = ["hatchling"]
36
+ build-backend = "hatchling.build"
37
+
38
+ [tool.hatch.build.targets.wheel]
39
+ packages = ["src/video_analyzer"]
40
+
41
+ [tool.hatch.build.targets.sdist]
42
+ exclude = ["docs", ".github", "dist"]
@@ -0,0 +1,31 @@
1
+ """Start the MCP server over stdio, list tools, call analyze_video on a URL or file.
2
+
3
+ Usage: uv run python scripts/smoke_mcp.py <url-or-file> [max_frames]
4
+ """
5
+
6
+ import asyncio
7
+ import sys
8
+
9
+ from mcp.client.session import ClientSession
10
+ from mcp.client.stdio import StdioServerParameters, stdio_client
11
+
12
+
13
+ async def main(source: str, frames: int) -> None:
14
+ params = StdioServerParameters(command=sys.executable, args=["-m", "video_analyzer.server"])
15
+ async with stdio_client(params) as (read, write):
16
+ async with ClientSession(read, write) as session:
17
+ await session.initialize()
18
+ tools = await session.list_tools()
19
+ print("tools:", [t.name for t in tools.tools])
20
+ result = await session.call_tool("analyze_video", {"url": source, "max_frames": frames},
21
+ read_timeout_seconds=600)
22
+ print("isError:", result.is_error)
23
+ for block in result.content:
24
+ if block.type == "text":
25
+ print(block.text[:1500])
26
+ else:
27
+ print(f"<{block.type} {getattr(block, 'mime_type', '')} {len(getattr(block, 'data', ''))} b64 chars>")
28
+
29
+
30
+ if __name__ == "__main__":
31
+ asyncio.run(main(sys.argv[1], int(sys.argv[2]) if len(sys.argv) > 2 else 4))
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.Mahanteshambi/video-analyzer",
4
+ "title": "Video Analyzer",
5
+ "description": "Let Claude watch Instagram Reels, YouTube Shorts, X and TikTok videos: local transcript, keyframes and metadata.",
6
+ "repository": {
7
+ "url": "https://github.com/Mahanteshambi/video-analyzer",
8
+ "source": "github"
9
+ },
10
+ "version": "0.1.0",
11
+ "packages": [
12
+ {
13
+ "registryType": "pypi",
14
+ "identifier": "vidlens",
15
+ "version": "0.1.0",
16
+ "runtimeHint": "uvx",
17
+ "packageArguments": [],
18
+ "transport": { "type": "stdio" }
19
+ }
20
+ ]
21
+ }
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: video-analysis
3
+ user-invocable: false
4
+ description: Analyze a short-form video (Instagram Reel, YouTube Short or video, X/Twitter video, TikTok) from a link the user shares. Use whenever the user pastes such a link and asks what it says, wants a summary, a breakdown of why it works, a fact-check, notes, or a script based on it. Also when they give a YouTube channel or TikTok profile and want its videos analysed together.
5
+ ---
6
+
7
+ # Analyzing a short video
8
+
9
+ 1. Call `analyze_video` with the link. Leave `max_frames` unset (it scales with length: about one frame per second, 8–20); set it lower to save tokens or to 20 for dense text-heavy videos; `get_transcript` instead when the user only wants the words.
10
+ 2. Read **both** the transcript and the keyframes. Many Reels are music-only with the message in on-screen text: read the overlay text from the frames. Keyframe times line up with transcript timestamps.
11
+ 3. If the tool reports a login/rate-limit error, tell the user to set `VIDEO_ANALYZER_COOKIES_BROWSER` (see the README) rather than retrying.
12
+
13
+ ## A whole channel
14
+
15
+ When the user gives a channel/profile link and wants patterns across its videos:
16
+ 1. `list_videos` with `sort="popular"` for "what works" questions, else `"recent"`. Default 10 videos; each takes 10-40s to process, so say so before going past ~10.
17
+ 2. Use `get_transcript` per video when the words carry the content; `analyze_video` with `max_frames` 4-6 when on-screen text or visuals matter (keeps image tokens down).
18
+ 3. Answer across videos: recurring hooks, formats, topics, lengths, and what the top performers do differently from the rest, citing specific videos.
19
+
20
+ Instagram and X profiles can't be listed: ask the user to paste the post links.
21
+
22
+ ## Default answer (when the user just shares a link)
23
+
24
+ - **One-line gist**: what the video is saying or selling.
25
+ - **Key points**: the actual content, including on-screen text, in order.
26
+ - **Hook (first 3s)**: what's said and shown in the opening frame, and why it stops the scroll.
27
+ - **Structure**: e.g. hook → problem → 3 tips → CTA, with rough timestamps.
28
+ - **CTA**: what the creator asks viewers to do.
29
+ - **Numbers**: views/likes/comments if available.
30
+
31
+ ## When asked
32
+
33
+ - **Fact-check**: list each factual claim with its timestamp and say whether it holds up; search the web for anything checkable. Be plain about claims that are misleading, especially health and finance advice.
34
+ - **Why it works / recreate it**: hook pattern, pacing (cuts per second from keyframe spacing), text-overlay style, emotional angle, then a script template the user can reuse.
35
+ - **Notes / summary**: concise bullet notes; quote the speaker only briefly.
36
+
37
+ Don't reproduce a song's lyrics if the audio is music; describe the track instead.
@@ -0,0 +1,3 @@
1
+ """video-analyzer: short-form video -> transcript + keyframes + metadata."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,52 @@
1
+ """Command line: `video-analyzer <url>`."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import json
7
+ import sys
8
+
9
+ from .fetch import FetchError, list_videos
10
+ from .media import MediaError
11
+ from .pipeline import analyze, to_markdown
12
+
13
+
14
+ def main(argv: list[str] | None = None) -> int:
15
+ p = argparse.ArgumentParser(prog="video-analyzer",
16
+ description="Transcript + keyframes + metadata for a short video URL or file.")
17
+ p.add_argument("source", help="Instagram/YouTube/X/TikTok URL, or a local video file")
18
+ p.add_argument("--frames", type=int, default=None,
19
+ help="max keyframes, up to 20 (default: about one per second, 8-20)")
20
+ p.add_argument("--no-transcript", action="store_true", help="skip Whisper")
21
+ p.add_argument("--refresh", action="store_true", help="ignore cache")
22
+ p.add_argument("--keep-media", action="store_true", help="keep the downloaded video in the cache folder")
23
+ p.add_argument("--json", action="store_true", help="print raw JSON instead of markdown")
24
+ p.add_argument("--list", type=int, metavar="N",
25
+ help="source is a channel/playlist: list its N videos instead of analysing")
26
+ p.add_argument("--popular", action="store_true", help="with --list: most viewed first")
27
+ args = p.parse_args(argv)
28
+ if args.list:
29
+ try:
30
+ r = list_videos(args.source, limit=args.list, sort="popular" if args.popular else "recent")
31
+ except FetchError as exc:
32
+ print(f"error: {exc}", file=sys.stderr)
33
+ return 1
34
+ if args.json:
35
+ print(json.dumps(r, indent=2, ensure_ascii=False))
36
+ else:
37
+ for v in r["videos"]:
38
+ views = f'{v["view_count"]:,} views' if v.get("view_count") else ""
39
+ print(f'{v["url"]} {views} {(v.get("title") or "")[:70]}')
40
+ return 0
41
+ try:
42
+ result = analyze(args.source, max_frames=args.frames, transcript=not args.no_transcript,
43
+ refresh=args.refresh, keep_media=args.keep_media)
44
+ except (FetchError, MediaError) as exc:
45
+ print(f"error: {exc}", file=sys.stderr)
46
+ return 1
47
+ print(json.dumps(result, indent=2, ensure_ascii=False) if args.json else to_markdown(result))
48
+ return 0
49
+
50
+
51
+ if __name__ == "__main__":
52
+ sys.exit(main())
@@ -0,0 +1,30 @@
1
+ """Settings, all overridable with environment variables."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ from pathlib import Path
7
+
8
+
9
+ def cache_dir() -> Path:
10
+ default = Path.home() / ".cache" / "video-analyzer"
11
+ path = Path(os.environ.get("VIDEO_ANALYZER_CACHE", default)).expanduser()
12
+ path.mkdir(parents=True, exist_ok=True)
13
+ return path
14
+
15
+
16
+ def whisper_model() -> str:
17
+ # tiny | base | small | medium | large-v3 | large-v3-turbo.
18
+ # large-v3-turbo: on an M-series CPU it was 2x faster than "small" on a 100s Hindi/English
19
+ # Reel and far more accurate (small produced garbled Devanagari). Cost: ~1.6 GB one-time download.
20
+ return os.environ.get("VIDEO_ANALYZER_WHISPER_MODEL", "large-v3-turbo")
21
+
22
+
23
+ def cookies_browser() -> str | None:
24
+ # e.g. "chrome", "safari", "firefox". Lets yt-dlp use your logged-in session for content that needs login.
25
+ return os.environ.get("VIDEO_ANALYZER_COOKIES_BROWSER") or None
26
+
27
+
28
+ def max_duration_seconds() -> int:
29
+ # Guard against someone pasting a 2-hour video into a "short" analyzer.
30
+ return int(os.environ.get("VIDEO_ANALYZER_MAX_DURATION", "900"))