josiahsiegel/claude-plugin-marketplace

ffmpeg-opencv-integration

Complete FFmpeg + OpenCV + Python integration guide for video processing pipelines.

View source
Original skill document

Rendered from the source repository. Headings, examples, code, tables, links, and referenced images are preserved.

FFmpeg + OpenCV Integration Guide

Use this skill when FFmpeg handles video I/O and OpenCV handles image processing. This SKILL is a lean orchestrator; full pipe patterns, library examples, and Modal recipes are preserved in references/opencv-pipelines-and-libraries.md.

When to Use

  • Decode with FFmpeg and process frames with OpenCV
  • Encode OpenCV-generated/processed frames with FFmpeg
  • Compare cv2.VideoCapture, subprocess pipes, PyAV, ffmpegcv, VidGear, and Decord
  • Fix RGB/BGR color bugs or (height, width) dimension-order bugs
  • Preserve audio while replacing processed video frames
  • Build GPU-assisted video I/O around CPU OpenCV processing

Library Selection

NeedBest optionWhy
Simple local filecv2.VideoCaptureBuilt-in and simple
Full FFmpeg format/protocol supportsubprocess pipeExact CLI behavior
GPU video I/OffmpegcvNVDEC/NVENC with OpenCV-like API
Network/RTSP streamingVidGearThreaded capture and stream helpers
ML batch loadingDecordFast random/batch frame access
Frame-level libav controlPyAVDirect FFmpeg library access

Critical Gotchas

  1. OpenCV is BGR. FFmpeg/PyAV/PIL/Decord often produce RGB. Convert explicitly.
  2. NumPy dimensions are `(height, width, channels)`. Pixel access is img[y, x], not img[x, y].
  3. Video filters can drop audio. Preserve or remux original audio intentionally.
  4. Release resources. Always close VideoCapture, pipes, writers, and PyAV containers.
  5. Rawvideo pipes require exact frame size. width * height * channels must match -pix_fmt.

Minimal Pipe Patterns

FFmpeg to OpenCV using BGR frames:

python
cmd = [
    "ffmpeg", "-i", input_path,
    "-f", "rawvideo", "-pix_fmt", "bgr24", "-"
]

OpenCV to FFmpeg using BGR frames:

python
cmd = [
    "ffmpeg", "-y",
    "-f", "rawvideo", "-vcodec", "rawvideo",
    "-s", f"{width}x{height}", "-pix_fmt", "bgr24",
    "-r", str(fps), "-i", "-",
    "-c:v", "libx264", "-preset", "fast", "-crf", "23",
    "-pix_fmt", "yuv420p", output_path
]

Core Workflow

  1. Probe input dimensions, fps, duration, and audio streams.
  2. Pick the I/O library based on the selection table.
  3. Lock pixel format at boundaries (bgr24 for OpenCV pipes; yuv420p for final H.264 output).
  4. Process frames in generators/batches; avoid loading full videos unless they are small.
  5. Preserve or re-encode audio explicitly.
  6. Verify output duration, fps, resolution, codec, and A/V sync.

Reference Map

  • references/opencv-pipelines-and-libraries.md - Full preserved reference: color/dimension gotchas, cleanup patterns, FFmpeg-to-OpenCV and OpenCV-to-FFmpeg pipes, bidirectional pipeline, ffmpegcv, VidGear, Decord, PyAV, Modal.com examples, GPU pipeline, cheat sheets, sources.

Related Skills

  • ffmpeg-python-integration-reference - Type-safe parameters, colors, time units
  • ffmpeg-pyav-integration - PyAV API details
  • ffmpeg-hardware-acceleration - GPU decode/encode and filter pipelines
from this repository

More skills

All skills
josiahsiegel
Community

ffmpeg-python-integration-reference

Authoritative Python-FFmpeg parameter integration reference ensuring type safety, accurate parameter mappings, and proper unit conversions. PROACTIVELY activate for: (1) ffmpeg-python library usage, (2) Python subprocess FFmpeg calls, (3) Caption/subtitle parameter mapping (drawtext, ASS), (4) Color format conversions (BGR, RGB, ABGR, ASS &HAABBGGRR), (5) Time unit conversions (seconds, centiseconds, milliseconds), (6) Type safety validation (int, float, string), (7) Coordinate systems, (8) Parameter range enforcement, (9) Frame pipe handling, (10) Error detection for type mismatches. Provides: Complete parameter type reference, color format conversion tables, time unit conversion formulas, validation patterns, working Python examples with proper typing.

installs
1
GitHub stars
54
Updated
Jun 18
josiahsiegel
Community

tailwindcss-mobile-first

Mobile-first responsive design patterns with Tailwind CSS v4 (2025-2026). PROACTIVELY activate for: (1) mobile-first design with Tailwind breakpoints (sm:, md:, lg:, xl:, 2xl:), (2) responsive utility ordering (default = mobile, then breakpoints), (3) responsive typography (text-base sm:text-lg lg:text-xl), (4) responsive grids and flexbox, (5) hide/show across breakpoints (hidden md:block), (6) max- breakpoints for desktop-down overrides, (7) container queries (@container) for component-level responsiveness, (8) safe-area insets and notch handling, (9) landscape vs portrait orientation, (10) touch vs hover (hover: with @media). Provides: breakpoint reference, mobile-first patterns, container-query examples, safe-area recipes, and touch/hover handling.

installs
1
GitHub stars
53
Updated
Jun 18
josiahsiegel
Community

tailwindcss-advanced-layouts

Tailwind CSS advanced layout techniques including CSS Grid and Flexbox patterns. PROACTIVELY activate for: (1) building complex layouts with CSS Grid, (2) grid-template-areas via Tailwind v4 arbitrary values, (3) responsive grid (grid-cols-, auto-fit, minmax), (4) Flexbox patterns (flex-1, flex-grow, gap), (5) sticky headers and footers, (6) holy grail layout, (7) masonry-style layouts, (8) container queries (@container) with Tailwind, (9) subgrid usage, (10) aspect-ratio utilities, (11) magazine-style multi-column layouts. Provides: Grid template recipes, container-query patterns, holy-grail templates, masonry alternatives, and aspect-ratio examples.

installs
1
GitHub stars
53
Updated
Jun 18