AI Multimodal Processing Skill
Process audio, images, videos, documents, and generate images using Google Gemini's multimodal API. Unified interface for all multimedia content understanding and generation.
Core Capabilities
Audio Processing
- Transcription with timestamps (up to 9.5 hours)
- Audio summarization and analysis
- Speech understanding and speaker identification
- Music and environmental sound analysis
- Text-to-speech generation with controllable voice
Image Understanding
- Image captioning and description
- Object detection with bounding boxes (2.0+)
- Pixel-level segmentation (2.5+)
- Visual question answering
- Multi-image comparison (up to 3,600 images)
- OCR and text extraction
Video Analysis
- Scene detection and summarization
- Video Q&A with temporal understanding
- Transcription with visual descriptions
- YouTube URL support
- Long video processing (up to 6 hours)
- Frame-level analysis
Document Extraction
- Native PDF vision processing (up to 1,000 pages)
- Table and form extraction
- Chart and diagram analysis
- Multi-page document understanding
- Structured data output (JSON schema)
- Format conversion (PDF to HTML/JSON)
Image Generation
- Text-to-image generation
- Image editing and modification
- Multi-image composition (up to 3 images)
- Iterative refinement
- Multiple aspect ratios (1:1, 16:9, 9:16, 4:3, 3:4)
- Controllable style and quality
Capability Matrix
| Task |
Audio |
Image |
Video |
Document |
Generation |
| Transcription |
✓ |
- |
✓ |
- |
- |
| Summarization |
✓ |
✓ |
✓ |
✓ |
- |
| Q&A |
✓ |
✓ |
✓ |
✓ |
- |
| Object Detection |
- |
✓ |
✓ |
- |
- |
| Text Extraction |
- |
✓ |
- |
✓ |
- |
| Structured Output |
✓ |
✓ |
✓ |
✓ |
- |
| Creation |
TTS |
- |
- |
- |
✓ |
| Timestamps |
✓ |
- |
✓ |
- |
- |
| Segmentation |
- |
✓ |
- |
- |
- |
Model Selection Guide
Gemini 2.5 Series (Recommended)
- gemini-2.5-pro: Highest quality, all features, 1M-2M context
- gemini-2.5-flash: Best balance, all features, 1M-2M context
- gemini-2.5-flash-lite: Lightweight, segmentation support
- gemini-2.5-flash-image: Image generation only
Gemini 2.0 Series
- gemini-2.0-flash: Fast processing, object detection
- gemini-2.0-flash-lite: Lightweight option
Feature Requirements
- Segmentation: Requires 2.5+ models
- Object Detection: Requires 2.0+ models
- Multi-video: Requires 2.5+ models
- Image Generation: Requires flash-image model
Context Windows
- 2M tokens: ~6 hours video (low-res) or ~2 hours (default)
- 1M tokens: ~3 hours video (low-res) or ~1 hour (default)
- Audio: 32 tokens/second (1 min = 1,920 tokens)
- PDF: 258 tokens/page (fixed)
- Image: 258-1,548 tokens based on size
Quick Start
Prerequisites
API Key Setup: Supports both Google AI Studio and Vertex AI.
The skill checks for GEMINI_API_KEY in this order:
- Process environment:
export GEMINI_API_KEY="your-key"
- Project root:
.env
.claude/.env
.claude/skills/.env
.claude/skills/ai-multimodal/.env
Get API key: https://aistudio.google.com/apikey
For Vertex AI:
export GEMINI_USE_VERTEX=true
export VERTEX_PROJECT_ID=your-gcp-project-id
export VERTEX_LOCATION=us-central1 # Optional
Install SDK:
pip install google-genai python-dotenv pillow
Common Patterns
Transcribe Audio:
python scripts/gemini_batch_process.py \
--files audio.mp3 \
--task transcribe \
--model gemini-2.5-flash
Analyze Image:
python scripts/gemini_batch_process.py \
--files image.jpg \
--task analyze \
--prompt "Describe this image" \
--output docs/assets/<output-name>.md \
--model gemini-2.5-flash
Process Video:
python scripts/gemini_batch_process.py \
--files video.mp4 \
--task analyze \
--prompt "Summarize key points with timestamps" \
--output docs/assets/<output-name>.md \
--model gemini-2.5-flash
Extract from PDF:
python scripts/gemini_batch_process.py \
--files document.pdf \
--task extract \
--prompt "Extract table data as JSON" \
--output docs/assets/<output-name>.md \
--format json
Generate Image:
python scripts/gemini_batch_process.py \
--task generate \
--prompt "A futuristic city at sunset" \
--output docs/assets/<output-file-name> \
--model gemini-2.5-flash-image \
--aspect-ratio 16:9
Optimize Media:
# Prepare large video for processing
python scripts/media_optimizer.py \
--input large-video.mp4 \
--output docs/assets/<output-file-name> \
--target-size 100MB
# Batch optimize multiple files
python scripts/media_optimizer.py \
--input-dir ./videos \
--output-dir docs/assets/optimized \
--quality 85
Convert Documents to Markdown:
# Convert to PDF
python scripts/document_converter.py \
--input document.docx \
--output docs/assets/document.md
# Extract pages
python scripts/document_converter.py \
--input large.pdf \
--output docs/assets/chapter1.md \
--pages 1-20
Supported Formats
Audio
- WAV, MP3, AAC, FLAC, OGG Vorbis, AIFF
- Max 9.5 hours per request
- Auto-downsampled to 16 Kbps mono
Images
- PNG, JPEG, WEBP, HEIC, HEIF
- Max 3,600 images per request
- Resolution: ≤384px = 258 tokens, larger = tiled
Video
- MP4, MPEG, MOV, AVI, FLV, MPG, WebM, WMV, 3GPP
- Max 6 hours (low-res) or 2 hours (default)
- YouTube URLs supported (public only)
Documents
- PDF only for vision processing
- Max 1,000 pages
- TXT, HTML, Markdown supported (text-only)
Size Limits
- Inline: <20MB total request
- File API: 2GB per file, 20GB project quota
- Retention: 48 hours auto-delete
Reference Navigation
For detailed implementation guidance, see:
Audio Processing
references/audio-processing.md - Transcription, analysis, TTS
- Timestamp handling and segment analysis
- Multi-speaker identification
- Non-speech audio analysis
- Text-to-speech generation
Image Understanding
references/vision-understanding.md - Captioning, detection, OCR
- Object detection and localization
- Pixel-level segmentation
- Visual question answering
- Multi-image comparison
Video Analysis
references/video-analysis.md - Scene detection, temporal understanding
- YouTube URL processing
- Timestamp-based queries
- Video clipping and FPS control
- Long video optimization
Document Extraction
references/document-extraction.md - PDF processing, structured output
- Table and form extraction
- Chart and diagram analysis
- JSON schema validation
- Multi-page handling
Image Generation
references/image-generation.md - Text-to-image, editing
- Prompt engineering strategies
- Image editing and composition
- Aspect ratio selection
- Safety settings
Cost Optimization
Token Costs
Input Pricing:
- Gemini 2.5 Flash: $1.00/1M input, $0.10/1M output
- Gemini 2.5 Pro: $3.00/1M input, $12.00/1M output
- Gemini 1.5 Flash: $0.70/1M input, $0.175/1M output
Token Rates:
- Audio: 32 tokens/second (1 min = 1,920 tokens)
- Video: ~300 tokens/second (default) or ~100 (low-res)
- PDF: 258 tokens/page (fixed)
- Image: 258-1,548 tokens based on size
TTS Pricing:
- Flash TTS: $10/1M tokens
- Pro TTS: $20/1M tokens
Best Practices
- Use
gemini-2.5-flash for most tasks (best price/performance)
- Use File API for files >20MB or repeated queries
- Optimize media before upload (see
media_optimizer.py)
- Process specific segments instead of full videos
- Use lower FPS for static content
- Implement context caching for repeated queries
- Batch process multiple files in parallel
Rate Limits
Free Tier:
- 10-15 RPM (requests per minute)
- 1M-4M TPM (tokens per minute)
- 1,500 RPD (requests per day)
YouTube Limits:
- Free tier: 8 hours/day
- Paid tier: No length limits
- Public videos only
Storage Limits:
- 20GB per project
- 2GB per file
- 48-hour retention
Error Handling
Common errors and solutions:
- 400: Invalid format/size - validate before upload
- 401: Invalid API key - check configuration
- 403: Permission denied - verify API key restrictions
- 404: File not found - ensure file uploaded and active
- 429: Rate limit exceeded - implement exponential backoff
- 500: Server error - retry with backoff
Scripts Overview
All scripts support unified API key detection and error handling:
gemini_batch_process.py: Batch process multiple media files
- Supports all modalities (audio, image, video, PDF)
- Progress tracking and error recovery
- Output formats: JSON, Markdown, CSV
- Rate limiting and retry logic
- Dry-run mode
media_optimizer.py: Prepare media for Gemini API
- Compress videos/audio for size limits
- Resize images appropriately
- Split long videos into chunks
- Format conversion
- Quality vs size optimization
document_converter.py: Convert documents to PDF
- Convert DOCX, XLSX, PPTX to PDF
- Extract page ranges
- Optimize PDFs for Gemini
- Extract images from PDFs
- Batch conversion support
Run any script with --help for detailed usage.
Resources
When to Use
Process and generate multimedia content using Google Gemini API.
Covers: AI Multimodal Processing Skill, Core Capabilities, Audio Processing, Image Understanding, Video Analysis.
1---2name: ai-multimodal3description: Process and generate multimedia content using Google Gemini API. Capabilities4 include analyze audio files (transcription with timestamps, summarization, speech5 understanding, music/sound analysis up to 9.5 hours), understand images (captioning,6 object detection, OCR, visual Q&A, segmentation), pr...7license: MIT8allowed-tools:9- Bash10- Read11- Write12- Edit13risk: safe14source: community15metadata:16 source: https://skillmd.com/skills/jantoniofc/ai-multimodal17---1819# AI Multimodal Processing Skill2021Process audio, images, videos, documents, and generate images using Google Gemini's multimodal API. Unified interface for all multimedia content understanding and generation.2223## Core Capabilities2425### Audio Processing26- Transcription with timestamps (up to 9.5 hours)27- Audio summarization and analysis28- Speech understanding and speaker identification29- Music and environmental sound analysis30- Text-to-speech generation with controllable voice3132### Image Understanding33- Image captioning and description34- Object detection with bounding boxes (2.0+)35- Pixel-level segmentation (2.5+)36- Visual question answering37- Multi-image comparison (up to 3,600 images)38- OCR and text extraction3940### Video Analysis41- Scene detection and summarization42- Video Q&A with temporal understanding43- Transcription with visual descriptions44- YouTube URL support45- Long video processing (up to 6 hours)46- Frame-level analysis4748### Document Extraction49- Native PDF vision processing (up to 1,000 pages)50- Table and form extraction51- Chart and diagram analysis52- Multi-page document understanding53- Structured data output (JSON schema)54- Format conversion (PDF to HTML/JSON)5556### Image Generation57- Text-to-image generation58- Image editing and modification59- Multi-image composition (up to 3 images)60- Iterative refinement61- Multiple aspect ratios (1:1, 16:9, 9:16, 4:3, 3:4)62- Controllable style and quality6364## Capability Matrix6566| Task | Audio | Image | Video | Document | Generation |67|------|:-----:|:-----:|:-----:|:--------:|:----------:|68| Transcription | ✓ | - | ✓ | - | - |69| Summarization | ✓ | ✓ | ✓ | ✓ | - |70| Q&A | ✓ | ✓ | ✓ | ✓ | - |71| Object Detection | - | ✓ | ✓ | - | - |72| Text Extraction | - | ✓ | - | ✓ | - |73| Structured Output | ✓ | ✓ | ✓ | ✓ | - |74| Creation | TTS | - | - | - | ✓ |75| Timestamps | ✓ | - | ✓ | - | - |76| Segmentation | - | ✓ | - | - | - |7778## Model Selection Guide7980### Gemini 2.5 Series (Recommended)81- **gemini-2.5-pro**: Highest quality, all features, 1M-2M context82- **gemini-2.5-flash**: Best balance, all features, 1M-2M context83- **gemini-2.5-flash-lite**: Lightweight, segmentation support84- **gemini-2.5-flash-image**: Image generation only8586### Gemini 2.0 Series87- **gemini-2.0-flash**: Fast processing, object detection88- **gemini-2.0-flash-lite**: Lightweight option8990### Feature Requirements91- **Segmentation**: Requires 2.5+ models92- **Object Detection**: Requires 2.0+ models93- **Multi-video**: Requires 2.5+ models94- **Image Generation**: Requires flash-image model9596### Context Windows97- **2M tokens**: ~6 hours video (low-res) or ~2 hours (default)98- **1M tokens**: ~3 hours video (low-res) or ~1 hour (default)99- **Audio**: 32 tokens/second (1 min = 1,920 tokens)100- **PDF**: 258 tokens/page (fixed)101- **Image**: 258-1,548 tokens based on size102103## Quick Start104105### Prerequisites106107**API Key Setup**: Supports both Google AI Studio and Vertex AI.108109The skill checks for `GEMINI_API_KEY` in this order:1101. Process environment: `export GEMINI_API_KEY="your-key"`1112. Project root: `.env`1123. `.claude/.env`1134. `.claude/skills/.env`1145. `.claude/skills/ai-multimodal/.env`115116**Get API key**: https://aistudio.google.com/apikey117118**For Vertex AI**:119```bash120export GEMINI_USE_VERTEX=true121export VERTEX_PROJECT_ID=your-gcp-project-id122export VERTEX_LOCATION=us-central1 # Optional123```124125**Install SDK**:126```bash127pip install google-genai python-dotenv pillow128```129130### Common Patterns131132**Transcribe Audio**:133```bash134python scripts/gemini_batch_process.py \135 --files audio.mp3 \136 --task transcribe \137 --model gemini-2.5-flash138```139140**Analyze Image**:141```bash142python scripts/gemini_batch_process.py \143 --files image.jpg \144 --task analyze \145 --prompt "Describe this image" \146 --output docs/assets/<output-name>.md \147 --model gemini-2.5-flash148```149150**Process Video**:151```bash152python scripts/gemini_batch_process.py \153 --files video.mp4 \154 --task analyze \155 --prompt "Summarize key points with timestamps" \156 --output docs/assets/<output-name>.md \157 --model gemini-2.5-flash158```159160**Extract from PDF**:161```bash162python scripts/gemini_batch_process.py \163 --files document.pdf \164 --task extract \165 --prompt "Extract table data as JSON" \166 --output docs/assets/<output-name>.md \167 --format json168```169170**Generate Image**:171```bash172python scripts/gemini_batch_process.py \173 --task generate \174 --prompt "A futuristic city at sunset" \175 --output docs/assets/<output-file-name> \176 --model gemini-2.5-flash-image \177 --aspect-ratio 16:9178```179180**Optimize Media**:181```bash182# Prepare large video for processing183python scripts/media_optimizer.py \184 --input large-video.mp4 \185 --output docs/assets/<output-file-name> \186 --target-size 100MB187188# Batch optimize multiple files189python scripts/media_optimizer.py \190 --input-dir ./videos \191 --output-dir docs/assets/optimized \192 --quality 85193```194195**Convert Documents to Markdown**:196```bash197# Convert to PDF198python scripts/document_converter.py \199 --input document.docx \200 --output docs/assets/document.md201202# Extract pages203python scripts/document_converter.py \204 --input large.pdf \205 --output docs/assets/chapter1.md \206 --pages 1-20207```208209## Supported Formats210211### Audio212- WAV, MP3, AAC, FLAC, OGG Vorbis, AIFF213- Max 9.5 hours per request214- Auto-downsampled to 16 Kbps mono215216### Images217- PNG, JPEG, WEBP, HEIC, HEIF218- Max 3,600 images per request219- Resolution: ≤384px = 258 tokens, larger = tiled220221### Video222- MP4, MPEG, MOV, AVI, FLV, MPG, WebM, WMV, 3GPP223- Max 6 hours (low-res) or 2 hours (default)224- YouTube URLs supported (public only)225226### Documents227- PDF only for vision processing228- Max 1,000 pages229- TXT, HTML, Markdown supported (text-only)230231### Size Limits232- **Inline**: <20MB total request233- **File API**: 2GB per file, 20GB project quota234- **Retention**: 48 hours auto-delete235236## Reference Navigation237238For detailed implementation guidance, see:239240### Audio Processing241- `references/audio-processing.md` - Transcription, analysis, TTS242 - Timestamp handling and segment analysis243 - Multi-speaker identification244 - Non-speech audio analysis245 - Text-to-speech generation246247### Image Understanding248- `references/vision-understanding.md` - Captioning, detection, OCR249 - Object detection and localization250 - Pixel-level segmentation251 - Visual question answering252 - Multi-image comparison253254### Video Analysis255- `references/video-analysis.md` - Scene detection, temporal understanding256 - YouTube URL processing257 - Timestamp-based queries258 - Video clipping and FPS control259 - Long video optimization260261### Document Extraction262- `references/document-extraction.md` - PDF processing, structured output263 - Table and form extraction264 - Chart and diagram analysis265 - JSON schema validation266 - Multi-page handling267268### Image Generation269- `references/image-generation.md` - Text-to-image, editing270 - Prompt engineering strategies271 - Image editing and composition272 - Aspect ratio selection273 - Safety settings274275## Cost Optimization276277### Token Costs278**Input Pricing**:279- Gemini 2.5 Flash: $1.00/1M input, $0.10/1M output280- Gemini 2.5 Pro: $3.00/1M input, $12.00/1M output281- Gemini 1.5 Flash: $0.70/1M input, $0.175/1M output282283**Token Rates**:284- Audio: 32 tokens/second (1 min = 1,920 tokens)285- Video: ~300 tokens/second (default) or ~100 (low-res)286- PDF: 258 tokens/page (fixed)287- Image: 258-1,548 tokens based on size288289**TTS Pricing**:290- Flash TTS: $10/1M tokens291- Pro TTS: $20/1M tokens292293### Best Practices2941. Use `gemini-2.5-flash` for most tasks (best price/performance)2952. Use File API for files >20MB or repeated queries2963. Optimize media before upload (see `media_optimizer.py`)2974. Process specific segments instead of full videos2985. Use lower FPS for static content2996. Implement context caching for repeated queries3007. Batch process multiple files in parallel301302## Rate Limits303304**Free Tier**:305- 10-15 RPM (requests per minute)306- 1M-4M TPM (tokens per minute)307- 1,500 RPD (requests per day)308309**YouTube Limits**:310- Free tier: 8 hours/day311- Paid tier: No length limits312- Public videos only313314**Storage Limits**:315- 20GB per project316- 2GB per file317- 48-hour retention318319## Error Handling320321Common errors and solutions:322- **400**: Invalid format/size - validate before upload323- **401**: Invalid API key - check configuration324- **403**: Permission denied - verify API key restrictions325- **404**: File not found - ensure file uploaded and active326- **429**: Rate limit exceeded - implement exponential backoff327- **500**: Server error - retry with backoff328329## Scripts Overview330331All scripts support unified API key detection and error handling:332333**gemini_batch_process.py**: Batch process multiple media files334- Supports all modalities (audio, image, video, PDF)335- Progress tracking and error recovery336- Output formats: JSON, Markdown, CSV337- Rate limiting and retry logic338- Dry-run mode339340**media_optimizer.py**: Prepare media for Gemini API341- Compress videos/audio for size limits342- Resize images appropriately343- Split long videos into chunks344- Format conversion345- Quality vs size optimization346347**document_converter.py**: Convert documents to PDF348- Convert DOCX, XLSX, PPTX to PDF349- Extract page ranges350- Optimize PDFs for Gemini351- Extract images from PDFs352- Batch conversion support353354Run any script with `--help` for detailed usage.355356## Resources357358- [Audio API Docs](https://ai.google.dev/gemini-api/docs/audio)359- [Image API Docs](https://ai.google.dev/gemini-api/docs/image-understanding)360- [Video API Docs](https://ai.google.dev/gemini-api/docs/video-understanding)361- [Document API Docs](https://ai.google.dev/gemini-api/docs/document-processing)362- [Image Gen Docs](https://ai.google.dev/gemini-api/docs/image-generation)363- [Get API Key](https://aistudio.google.com/apikey)364- [Pricing](https://ai.google.dev/pricing)365366## When to Use367368Process and generate multimedia content using Google Gemini API.369370Covers: AI Multimodal Processing Skill, Core Capabilities, Audio Processing, Image Understanding, Video Analysis.