FFmpeg Skill
Hard rules
Never overwrite the original. Write to a new file. Derive the name if none given:
video.mp4becomesvideo_compressed.mp4. Never use-yon the same path as the input.Never destroy quality. Minimum floors:
Codec Flag Floor Good default H.264 (libx264) -crf28 max 18-23 H.265 (libx265) -crf32 max 24-28 VP9 (libvpx-vp9) -crf40 max 31-36 AAC -b:a128k min 192k MP3 -q:a4 max 2 If the target size requires going below these floors, say so. Offer the best size achievable at the floor instead.
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:
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
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. |