media2html

media2html

Converts images, videos, and audio into structured, cacheable HTML representations optimized for text-based LLM reasoning.

Category
访问服务器

README

Media2HTML: A VLM-Free Pure Compiler for Multimodal Agents

Disclaimer: Please understand this is V0.01 and still very experimental. It is the product of a personal theory and nothing more.

A tool that converts images, videos, and audio into structured, cacheable HTML representations optimized for text-based LLM reasoning.

V0.0.1 — Pure Compiler Architecture


Concept

Modern multimodal AI agents need to reason about media files, but LLMs are fundamentally text-based. Traditional approaches — passing raw base64 images or unstructured VLM captions — suffer from massive token overhead, hallucination risk, and GPU contention.

Media2HTML eliminates all of this. It extracts structured facts (objects, text, colors, spatial relations, semantic tags) using deterministic algorithms, then compiles them into semantic HTML that LLMs understand natively. Zero Vision-Language Models in the runtime loop.

Key benefits:

  • (To be dertimined) token reduction vs. raw base64 images
  • 0 GB VRAM — all extraction runs on CPU, leaving GPU free for the text LLM
  • 100% deterministic — same input always produces the same output
  • Zero hallucination — no generative model in the pipeline
  • Instant caching — repeated file analysis returns in <1ms

V0.0.1 Stack

Component Technology Purpose
Object Detection YOLO-World + SAHI Open-vocabulary detection with sliced inference for 4K+ images
Z-Axis Layout Depth-Anything V2 Foreground / midground / background categorization
Semantic Tags CLIP (openai/clip-vit-base-patch32) Zero-shot scene tagging (rain, night, cherry blossom, etc.)
Text Extraction RapidOCR CPU-only OCR with paragraph grouping
Visual Maps ASCILINE Token-optimized 512-cell grid for visual reasoning
Audio Whisper + Pyannote Transcription and speaker diarization
Video scenedetect + FFmpeg Scene detection with keyframe extraction

Setup

1. Install System Dependencies

sudo apt install ffmpeg portaudio19-dev

2. Install Python Packages

pip install -e .

3. Environment Variables (Optional)

export HF_TOKEN="hf_..."  # Required for Pyannote audio diarization

Usage

As a Python Library

from media2html import media_to_html

# Image
html = media_to_html("path/to/image.jpg", mode="rich")

# Video (with interleaved audio)
html = media_to_html("path/to/video.mp4", mode="compact")

# Audio
html = media_to_html("path/to/audio.wav", mode="minimal")

As an MCP Server

# Start the MCP server
python3 -m media2html.mcp_server

# Or run directly
python3 media2html/mcp_server.py

Agents call the transcode_media tool to analyze any local media file.


Modes

Mode Content Token Count
minimal Caption + top objects + colors ~200
compact + OCR + visual grid ~800
rich + spatial relations, semantic tags, depth scene, accent colors ~2500

Output Format

Media2HTML produces semantic HTML that leverages LLM pretraining priors:

<image-summary width="1376" height="768" source="photo.png">
  <caption>Scene contains: car, person, umbrella. Text detected: 'LOFUGA'. Dominant color: #303048. Tags: rain, wet road.</caption>
  <spatial-graph>
    <rel>car is left of person</rel>
    <rel>person is above car</rel>
  </spatial-graph>
  <semantic-tags>
    <t>rain</t>
    <t>wet road</t>
  </semantic-tags>
  <scene>
    <foreground>car</foreground>
    <background>person, umbrella</background>
  </scene>
  <accent-colors>
    <c hex="#e0c4c4" pct="0.04" label="vibrant"/>
  </accent-colors>
  <objects>
    <obj label="car" bbox="0.277,0.438,0.758,1.000"/>
  </objects>
  <text-regions>
    <t bbox="0.350,0.750,0.412,0.794">LOFUGA</t>
  </text-regions>
  <colors>
    <c hex="#303048" pct="0.08"/>
  </colors>
</image-summary>

Architecture

media2html/
├── pyproject.toml           # Package configuration
├── requirements.txt         # Dependencies
├── README.md                # This file
├── TECHNICAL_WHITEPAPER.md  # Full architecture documentation
├── test_media2html.py       # Test suite
└── media2html/
    ├── __init__.py          # Package exports
    ├── cache.py             # Disk-based caching (diskcache + MD5)
    ├── html_builder.py      # Data model + HTML generation
    ├── pipeline.py          # Main extraction pipeline
    ├── mcp_server.py        # MCP server for agent integration
    └── extractors/
        ├── __init__.py
        ├── vision.py        # YOLO-World + Depth-Anything + CLIP + RapidOCR
        ├── audio.py         # Whisper + Pyannote
        └── video.py         # Scene detection + keyframes

Performance

Metric Value
Token reduction vs. raw base64 to be determined
Extraction latency (minimal) ~200ms
Extraction latency (rich) ~700ms
GPU VRAM required 0 GB (all CPU)
Deterministic output 100%
Hallucination risk 0%
Cache hit latency <1ms

License Creative Commons

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选