Complete FFmpeg + OpenCV + Python integration guide for video processing pipelines. PROACTIVELY activate for: (1) FFmpeg to OpenCV frame handoff, (2) cv2.VideoCapture vs ffmpeg subprocess, (3) BGR/RGB color format conversion gotchas, (4) Frame dimension order img[y,x] vs img[x,y], (5) ffmpegcv GPU-accelerated video I/O, (6) VidGear multi-threaded streaming, (7) Decord batch video loading for ML, (8) PyAV frame-level processing, (9) Audio stream preservation with video filters, (10) Memory-efficient frame generators, (11) OpenCV + FFmpeg + Modal parallel processing, (12) Pipe frames between FFmpeg and OpenCV. Provides: Color format conversion patterns, coordinate system gotchas, library selection guide, memory management, subprocess pipe patterns, GPU-accelerated alternatives to cv2.VideoCapture. Ensures: Correct integration between FFmpeg and OpenCV without color/coordinate bugs. See also: ffmpeg-python-integration-reference for type-safe parameter mappings.
View on GitHubJosiahSiegel/claude-plugin-marketplace
ffmpeg-master
plugins/ffmpeg-master/skills/ffmpeg-opencv-integration/SKILL.md
January 20, 2026
Select agents to install to:
npx add-skill https://github.com/JosiahSiegel/claude-plugin-marketplace/blob/main/plugins/ffmpeg-master/skills/ffmpeg-opencv-integration/SKILL.md -a claude-code --skill ffmpeg-opencv-integrationInstallation paths:
.claude/skills/ffmpeg-opencv-integration/## Quick Reference
| Task | Best Library | Why |
|------|--------------|-----|
| Simple video read | OpenCV `cv2.VideoCapture` | Built-in, easy API |
| GPU video I/O | ffmpegcv | NVDEC/NVENC, OpenCV-compatible API |
| Multi-threaded streaming | VidGear | RTSP/RTMP, camera capture |
| ML batch loading | Decord | 2x faster than OpenCV, batch GPU decode |
| Frame-level precision | PyAV | Direct libav access, precise seeking |
| Complex filter graphs | ffmpeg-python subprocess | Full FFmpeg power |
| Color Format | Library | Conversion |
|--------------|---------|------------|
| BGR | OpenCV (cv2) | `cv2.cvtColor(img, cv2.COLOR_BGR2RGB)` |
| RGB | FFmpeg, PIL, PyAV | `cv2.cvtColor(img, cv2.COLOR_RGB2BGR)` |
| YUV | FFmpeg internal | Convert to RGB/BGR for processing |
## When to Use This Skill
Use for **FFmpeg + OpenCV combined workflows**:
- Reading video with FFmpeg, processing frames with OpenCV
- Piping frames between FFmpeg and OpenCV processes
- GPU-accelerated video I/O with OpenCV processing
- Fixing color format mismatches (BGR vs RGB)
- Memory-efficient processing of large videos
- Parallel frame processing on Modal.com
---
# FFmpeg + OpenCV Integration Guide
Complete guide to combining FFmpeg's video I/O power with OpenCV's image processing capabilities.
## Critical Gotchas (Must Know!)
### 1. Color Format Mismatch (BGR vs RGB)
**The #1 source of bugs in FFmpeg + OpenCV pipelines.**
```python
import cv2
import numpy as np
# OpenCV uses BGR by default
img_bgr = cv2.imread("image.jpg") # BGR format!
# FFmpeg outputs RGB by default (in most configs)
# PyAV outputs RGB
# PIL/Pillow uses RGB
# WRONG: Using FFmpeg RGB output directly with OpenCV
# Colors will be swapped (red becomes blue)
# CORRECT: Always convert explicitly
def bgr_to_rgb(frame: np.ndarray) -> np.ndarray:
"""Convert OpenCV BGR to RGB for FFmpeg/PIL/ML."""
return cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
def rgb_to_bgr(frame: np.ndarray) -> np.ndarray:
"""Convert RGB (FFmp