# Ffmpeg

> Use this skill whenever the user asks to process, convert, compress, trim, merge, extract, or otherwise manipulate video or audio files using ffmpeg. Covers format conversion, compression, clipping, filtering, and any other ffmpeg operation.

- Skill: `sakydev/ffmpeg` (Agent Skill)
- Install (CLI): `npx skillmds@latest add sakydev/ffmpeg`
- Raw SKILL.md: https://api.skillmd.com/api/skills/sakydev/ffmpeg/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: sakydev (https://skillmd.com/u/sakydev)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/sakydev/ffmpeg

---


# FFmpeg Skill

## Hard rules

1. **Never overwrite the original.** Write to a new file. Derive the name if none given: `video.mp4` becomes `video_compressed.mp4`. Never use `-y` on the same path as the input.

2. **Never destroy quality.** Minimum floors:

   | Codec | Flag | Floor | Good default |
   |---|---|---|---|
   | H.264 (libx264) | `-crf` | 28 max | 18-23 |
   | H.265 (libx265) | `-crf` | 32 max | 24-28 |
   | VP9 (libvpx-vp9) | `-crf` | 40 max | 31-36 |
   | AAC | `-b:a` | 128k min | 192k |
   | MP3 | `-q:a` | 4 max | 2 |

   If the target size requires going below these floors, say so. Offer the best size achievable at the floor instead.

3. **File over 1 GB? Stop.** Say: "This file is [size]. Processing will take a while and produce large intermediates. Continue?" Only proceed with confirmation.

## Step 1 — Inspect first

Always run this before building any command:

```bash
ffprobe -v quiet -print_format json -show_format -show_streams "<input>"
```

Read the size, codec, resolution, bitrate, duration. Check the 1 GB rule here.

## Step 2 — Pick the right approach

**Compression:** `libx264 -crf 23 -preset slow`. Copy audio unless asked otherwise: `-c:a copy`.

**Format conversion:** If only the container changes, use `-c copy`. No re-encode. No quality loss. Instant.

**Trimming:** `-ss` before `-i` for fast seek. `-c copy` when possible.

**Audio extraction:** `-vn -c:a copy` to extract without re-encoding.

**Scaling:** `-vf scale=1280:-2` to preserve aspect ratio. Always pair with a re-encode.

## Step 3 — Show the command before running

```bash
ffmpeg -i "input.mp4" -c:v libx264 -crf 23 -preset slow -c:a copy "input_compressed.mp4"
# -crf 23     : quality (lower = better)
# -preset slow : smaller file, same quality
# -c:a copy   : audio untouched
```

Show it. Explain non-obvious flags. Ask before running on large files or long operations.

## Step 4 — Report after

- Original size vs output size.
- Any quality warnings from stderr.
- Output file path.

Output larger than input? Flag it. Suggest `-c copy` if applicable.

## Concerns

| Situation | Say |
|---|---|
| Target size needs CRF above floor | "Hitting [size] needs CRF [N]. Below acceptable quality. Best I can do at the floor is [size]." |
| User says "compress as much as possible" | "How small do you need it? Below CRF [N] it degrades noticeably." |
| Input already matches target format | "Already [format]. I can remux without re-encoding. Lossless and instant." |
| User asks to overwrite original | "Not overwriting the original. Saving as [derived name] instead." |
| File over 1 GB | Stop. Confirm before proceeding. |

