Skip to main content

Video analysis using Google's Gemini 2.5 Flash API

Project description

Merleau

"The world is not what I think, but what I live through." — Maurice Merleau-Ponty

A CLI tool for video understanding using Google's Gemini API. Named after Maurice Merleau-Ponty, the phenomenologist philosopher whose work on perception inspires how this tool helps you perceive your videos.

Website · Web App · PyPI · GitHub

https://github.com/user-attachments/assets/e2c5b476-ddab-49ab-a35c-9ae5e880c25c

Why Merleau?

Google Gemini is the only major AI provider with native video understanding—Claude doesn't support video, and GPT-4o requires frame extraction workarounds. Merleau is the first CLI that actually understands video rather than analyzing frames.

Features

  • Native Gemini video processing - Upload and analyze videos directly
  • YouTube URL support - Analyze videos directly from YouTube (free preview)
  • Customizable prompts - Ask any question about your video
  • Cost estimation - Token usage tracking and cost breakdown
  • Multiple models - Support for different Gemini models
  • Web UI - Streamlit app for browser-based analysis

Installation

Using uv (recommended):

uv sync

Or install from PyPI:

pip install merleau

Configuration

  1. Get a Gemini API key from Google AI Studio
  2. Set the API key as an environment variable or create a .env file:
    GEMINI_API_KEY=your_api_key_here
    

Usage

# Basic video analysis
ponty video.mp4

# Custom prompt
ponty video.mp4 -p "Summarize the key points in this video"

# Use a different model
ponty video.mp4 -m gemini-2.0-flash

# Hide cost information
ponty video.mp4 --no-cost

Web UI

Try it online: https://merleau.streamlit.app/

Or run locally:

pip install merleau[web]
streamlit run streamlit_app.py

Options

Option Description
-p, --prompt Prompt for the analysis (default: "Explain what happens in this video")
-m, --model Gemini model to use (default: gemini-2.5-flash)
--no-cost Hide usage and cost information

Reducing Costs with Compression

Compressing videos before analysis can reduce API costs by ~10-15% without degrading analysis quality. Gemini's token count is affected by video resolution and bitrate.

Quick Compression with ffmpeg

# Basic compression (recommended)
ffmpeg -i input.mp4 -vcodec libx264 -crf 28 -preset medium -vf "scale=1280:-2" output.mp4

# Aggressive compression (smaller file, lower quality)
ffmpeg -i input.mp4 -vcodec libx264 -crf 32 -preset medium -vf "scale=640:-2" output.mp4

# Keep audio (for speech analysis)
ffmpeg -i input.mp4 -vcodec libx264 -crf 28 -preset medium -vf "scale=1280:-2" -acodec aac -b:a 128k output.mp4

Compression Options Explained

Option Description
-crf 28 Quality level (18-28 recommended, higher = smaller file)
-preset medium Encoding speed/quality tradeoff
-vf "scale=1280:-2" Resize to 1280px width, maintain aspect ratio
-an Remove audio (if not needed)
-acodec aac -b:a 128k Compress audio to 128kbps AAC

Cost Comparison Example

Version File Size Prompt Tokens Input Cost
Original (1080p) 52 MB 14,757 $0.00221
Compressed (720p) 2.6 MB 13,157 $0.00197
Savings 95% 10.8% 10.8%

Output

The CLI provides:

  • Video content analysis from Gemini
  • Token usage breakdown (prompt, response, total)
  • Estimated cost based on Gemini pricing

Pricing Reference

Gemini 2.5 Flash (as of 2025):

  • Input: $0.15 per 1M tokens (text/image), $0.075 per 1M tokens (video)
  • Output: $0.60 per 1M tokens, $3.50 for thinking tokens

A 1-hour video costs approximately $0.11-0.32 to analyze.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

merleau-0.4.1.tar.gz (127.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

merleau-0.4.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file merleau-0.4.1.tar.gz.

File metadata

  • Download URL: merleau-0.4.1.tar.gz
  • Upload date:
  • Size: 127.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for merleau-0.4.1.tar.gz
Algorithm Hash digest
SHA256 f420525390be6b9da4b7defab99d9ac79f99195f4296b823215abe0364d133cb
MD5 be570e6fbe618222f3ae00637fb76ca6
BLAKE2b-256 29f61b5d4e715eeb4c2ca05c3240662d59020f2ea2f7fab412ccdb52b0b702ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for merleau-0.4.1.tar.gz:

Publisher: python-publish.yml on yanndebray/merleau

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file merleau-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: merleau-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for merleau-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 25387cb8a8a27561b41cf6ca9d603dfa314f2634e6e408f1f04bbee003d1a01c
MD5 e9514b6caf920d07d1259b3c67720b29
BLAKE2b-256 3d07c319c27dd2f6a323121a81689ce05e6f4671e7a123fc32adbbff8c3490c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for merleau-0.4.1-py3-none-any.whl:

Publisher: python-publish.yml on yanndebray/merleau

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page