ffmpeg-usage
ffmpeg recipes and best practices: convert, concatenate, merge, resize, compress, GIF creation, audio extraction, subtitles, optimize for social platforms.
Best use case
ffmpeg-usage is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
ffmpeg recipes and best practices: convert, concatenate, merge, resize, compress, GIF creation, audio extraction, subtitles, optimize for social platforms.
Teams using ffmpeg-usage should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/ffmpeg-usage/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How ffmpeg-usage Compares
| Feature / Agent | ffmpeg-usage | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
ffmpeg recipes and best practices: convert, concatenate, merge, resize, compress, GIF creation, audio extraction, subtitles, optimize for social platforms.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# ffmpeg Usage
## Overview
This Skill provides comprehensive video and audio processing capabilities using ffmpeg. It includes battle-tested commands and workflows for common multimedia tasks, platform-specific optimizations, and best practices for quality and file size management.
**Version:** 1.0.0
**Requirements:** ffmpeg >= 4.0, ffprobe (optional but recommended)
Claude should use this Skill whenever users mention video or audio processing tasks, format conversions, social media optimization, or multimedia editing.
## When to Apply
Use this Skill when the user requests:
- Video format conversion (MP4, WebM, MOV, etc.)
- Resolution scaling or aspect ratio changes
- GIF creation from videos
- Audio extraction or format conversion
- Video editing (trim, merge, speed adjustment, rotation)
- Subtitle processing (burn-in, soft subs, extraction)
- Video compression or optimization
- Platform-specific formatting (YouTube, Instagram, TikTok, Twitter)
- Thumbnail or frame extraction
- Batch processing of video/audio files
## Prerequisites
Before using this skill, ensure ffmpeg is installed:
```bash
# macOS
brew install ffmpeg
# Ubuntu/Debian
sudo apt-get install ffmpeg
# Windows (with Chocolatey)
choco install ffmpeg
```
Verify installation:
```bash
ffmpeg -version
```
## Supported Operations
### 1. Format Conversion
Convert between video formats with optimized settings.
**MP4 to WebM:**
```bash
ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 30 -b:v 0 -c:a libopus output.webm
```
**MOV to MP4:**
```bash
ffmpeg -i input.mov -c:v libx264 -c:a aac -strict experimental output.mp4
```
**Any to MP4 (universal compatibility):**
```bash
ffmpeg -i input.* -c:v libx264 -preset medium -crf 23 -c:a aac -b:a 128k output.mp4
```
### 2. Resolution Adjustment
Resize videos while maintaining aspect ratio.
**Scale to 720p:**
```bash
ffmpeg -i input.mp4 -vf scale=-1:720 -c:a copy output_720p.mp4
```
**Scale to 1080p:**
```bash
ffmpeg -i input.mp4 -vf scale=-1:1080 -c:a copy output_1080p.mp4
```
**Scale to specific width (auto height):**
```bash
ffmpeg -i input.mp4 -vf scale=1280:-1 -c:a copy output.mp4
```
**Scale with padding (letterbox):**
```bash
ffmpeg -i input.mp4 -vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2" output.mp4
```
### 3. GIF Creation
Create high-quality GIFs from videos with optimized file size.
**Basic GIF (10 fps):**
```bash
ffmpeg -i input.mp4 -vf "fps=10,scale=480:-1:flags=lanczos" output.gif
```
**High-quality GIF with palette:**
```bash
# Generate palette
ffmpeg -i input.mp4 -vf "fps=10,scale=480:-1:flags=lanczos,palettegen" palette.png
# Create GIF using palette
ffmpeg -i input.mp4 -i palette.png -filter_complex "fps=10,scale=480:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif
```
**GIF from specific time range:**
```bash
ffmpeg -ss 00:00:10 -t 5 -i input.mp4 -vf "fps=10,scale=480:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" output.gif
```
### 4. Audio Operations
Extract, convert, and manipulate audio streams.
**Extract audio to MP3:**
```bash
ffmpeg -i input.mp4 -vn -acodec libmp3lame -q:a 2 output.mp3
```
**Extract audio to WAV:**
```bash
ffmpeg -i input.mp4 -vn -acodec pcm_s16le -ar 44100 -ac 2 output.wav
```
**Convert audio format:**
```bash
ffmpeg -i input.wav -c:a aac -b:a 192k output.m4a
```
**Add background music:**
```bash
ffmpeg -i video.mp4 -i music.mp3 -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 -shortest output.mp4
```
**Mix audio (overlay):**
```bash
ffmpeg -i video.mp4 -i music.mp3 -filter_complex "[0:a][1:a]amix=inputs=2:duration=first" -c:v copy output.mp4
```
### 5. Video Editing
Trim, concatenate, and modify videos.
**Trim video:**
```bash
# From 10s to 30s
ffmpeg -i input.mp4 -ss 00:00:10 -to 00:00:30 -c copy output.mp4
# Duration-based (10s starting from 5s)
ffmpeg -i input.mp4 -ss 00:00:05 -t 10 -c copy output.mp4
```
**Concatenate videos:**
Choose method based on format and compatibility:
**Method 1: Concat Protocol (Preferred - No temporary files needed)**
```bash
# For MPEG formats: .ts, .mpg, .mpeg, .mp3, .aac, etc.
# Direct concatenation without creating list file
ffmpeg -i "concat:file1.mp3|file2.mp3|file3.mp3" -c copy output.mp3
ffmpeg -i "concat:video1.ts|video2.ts|video3.ts" -c copy output.ts
# Works with: TS, MPEG-1, MPEG-2, MP3, AAC
# Does NOT work with: MP4, MOV, MKV (use Method 2 instead)
```
**Method 2: Concat Demuxer (For MP4, MOV, MKV)**
```bash
# Use process substitution to avoid temporary files
ffmpeg -f concat -safe 0 -i <(printf "file '%s'\n" video1.mp4 video2.mp4 video3.mp4) -c copy output.mp4
# If shell doesn't support process substitution:
printf "file '%s'\n" video1.mp4 video2.mp4 video3.mp4 > list.txt
ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp4
rm list.txt
```
**Method 3: Concat Filter (When re-encoding is acceptable)**
```bash
# Use when videos have different codecs/resolutions
ffmpeg -i video1.mp4 -i video2.mp4 -i video3.mp4 \
-filter_complex "[0:v][0:a][1:v][1:a][2:v][2:a]concat=n=3:v=1:a=1[v][a]" \
-map "[v]" -map "[a]" output.mp4
```
**Format Decision Guide:**
- `.mp3`, `.aac`, `.ts`, `.mpg`, `.mpeg` → Use concat protocol (Method 1)
- `.mp4`, `.mov`, `.mkv` → Use concat demuxer (Method 2)
- Different codecs/resolutions → Use concat filter (Method 3)
**Speed up/slow down:**
```bash
# 2x speed
ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" -an output.mp4
# 0.5x speed (slow motion)
ffmpeg -i input.mp4 -filter:v "setpts=2.0*PTS" output.mp4
```
**Rotate video:**
```bash
# 90 degrees clockwise
ffmpeg -i input.mp4 -vf "transpose=1" output.mp4
# 180 degrees
ffmpeg -i input.mp4 -vf "transpose=2,transpose=2" output.mp4
```
### 6. Subtitle Processing
Add, extract, or burn subtitles.
**Burn subtitles into video:**
```bash
ffmpeg -i input.mp4 -vf subtitles=subtitles.srt output.mp4
```
**Add soft subtitles:**
```bash
ffmpeg -i input.mp4 -i subtitles.srt -c copy -c:s mov_text output.mp4
```
**Extract subtitles:**
```bash
ffmpeg -i input.mp4 -map 0:s:0 subtitles.srt
```
### 7. Thumbnail Extraction
Extract frames as images.
**Single frame at specific time:**
```bash
ffmpeg -i input.mp4 -ss 00:00:05 -vframes 1 thumbnail.jpg
```
**Multiple thumbnails:**
```bash
# One frame every 10 seconds
ffmpeg -i input.mp4 -vf fps=1/10 thumb%04d.jpg
# First 10 frames
ffmpeg -i input.mp4 -vframes 10 frame%04d.png
```
### 8. Compression & Optimization
Reduce file size while maintaining quality.
**Compress video (balanced):**
```bash
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset medium -c:a aac -b:a 128k output.mp4
```
**High compression (smaller file):**
```bash
ffmpeg -i input.mp4 -c:v libx264 -crf 28 -preset veryslow -c:a aac -b:a 96k output.mp4
```
**Compress for web:**
```bash
ffmpeg -i input.mp4 -c:v libx264 -preset medium -crf 23 -movflags +faststart -c:a aac -b:a 128k output.mp4
```
## Platform-Specific Presets
### YouTube Optimization
```bash
ffmpeg -i input.mp4 \
-c:v libx264 -preset slow -crf 18 \
-c:a aac -b:a 192k \
-pix_fmt yuv420p \
-movflags +faststart \
youtube.mp4
```
### Instagram Story (9:16)
```bash
ffmpeg -i input.mp4 \
-vf "scale=1080:1920:force_original_aspect_ratio=decrease,pad=1080:1920:(ow-iw)/2:(oh-ih)/2" \
-c:v libx264 -preset medium -crf 23 \
-c:a aac -b:a 128k \
-t 15 \
instagram_story.mp4
```
### Twitter/X (16:9, max 2:20)
```bash
ffmpeg -i input.mp4 \
-vf scale=1280:720 \
-c:v libx264 -preset medium -crf 23 \
-c:a aac -b:a 128k \
-t 140 \
twitter.mp4
```
### TikTok (9:16)
```bash
ffmpeg -i input.mp4 \
-vf "scale=1080:1920:force_original_aspect_ratio=decrease,pad=1080:1920:(ow-iw)/2:(oh-ih)/2" \
-c:v libx264 -preset medium -crf 23 \
-c:a aac -b:a 128k \
-t 60 \
tiktok.mp4
```
## Common Use Cases
### Screen Recording Optimization
```bash
# Reduce file size of screen recordings
ffmpeg -i screen_recording.mov \
-c:v libx264 -preset medium -crf 23 \
-vf "scale=1920:-1" \
-c:a aac -b:a 128k \
optimized.mp4
```
### Batch Conversion
```bash
# Convert all MOV files to MP4
for i in *.mov; do
ffmpeg -i "$i" -c:v libx264 -crf 23 -c:a aac "${i%.mov}.mp4"
done
```
### Create Video from Images
```bash
# From image sequence
ffmpeg -framerate 30 -pattern_type glob -i '*.jpg' \
-c:v libx264 -pix_fmt yuv420p \
output.mp4
# Single image to video (5 seconds)
ffmpeg -loop 1 -i image.jpg -c:v libx264 -t 5 -pix_fmt yuv420p output.mp4
```
## Best Practices
1. **Always check input file first:**
```bash
ffmpeg -i input.mp4
# Or use ffprobe for detailed info
ffprobe -v quiet -print_format json -show_format -show_streams input.mp4
```
2. **Use `-c copy` when possible to avoid re-encoding:**
```bash
ffmpeg -i input.mp4 -ss 00:01:00 -t 30 -c copy output.mp4
```
3. **Preview before processing with `-t` flag:**
```bash
# Test on first 10 seconds
ffmpeg -i input.mp4 -t 10 [other options] test.mp4
```
4. **Use appropriate CRF values:**
- 18 = visually lossless
- 23 = high quality (default)
- 28 = acceptable quality, smaller file
- Range: 0 (lossless) to 51 (worst quality)
5. **Add `-movflags +faststart` for web videos:**
- Enables progressive playback
- Moves metadata to beginning of file
## Error Handling
When using this skill, always:
1. Verify input file exists and is readable
2. Check ffmpeg installation before processing
3. Validate output path is writable
4. Handle errors gracefully with appropriate messages
5. Show progress when processing large files
## Guidelines for Claude
When a user requests video/audio processing:
1. **Identify the task type** from the request
2. **Select appropriate command** from this skill
3. **Verify prerequisites** (ffmpeg installed, input file exists)
4. **Explain what the command does** before executing
5. **Execute the command** with proper error handling
6. **Verify the output** was created successfully
7. **Suggest optimizations** if applicable
For complex workflows, break down into steps and explain each one.
**For video concatenation:** Use process substitution with printf when possible to avoid temporary files (see Method 2 in concatenate section). Fall back to temporary list.txt only if needed.
## Examples
**User:** "Convert this MOV file to MP4"
**Response:** Use the MOV to MP4 conversion command with H.264 codec
**User:** "Make a GIF from this video, but only 5 seconds starting at 10 seconds in"
**Response:** Use GIF creation with time range specification
**User:** "I need to resize this 4K video to 1080p for web"
**Response:** Combine resolution scaling with web optimization preset
**User:** "Extract the audio as MP3"
**Response:** Use audio extraction command with MP3 codec
## References
- FFmpeg Official Documentation: https://ffmpeg.org/documentation.html
- FFmpeg Wiki: https://trac.ffmpeg.org/wiki
- Supported Codecs: https://ffmpeg.org/ffmpeg-codecs.html
- Filter Documentation: https://ffmpeg.org/ffmpeg-filters.htmlRelated Skills
ai-usage-coach
Help users get more value from AI assistants by suggesting better prompting techniques, surfacing underused features, and identifying workflow improvements. Use when users ask things like "how can I use Claude better?", "what features am I missing?", "give me tips for prompting", "what can you do?", "I feel like I'm not getting the most out of this", or when they explicitly ask for help improving their AI usage. Also use when users seem frustrated with results or are clearly using suboptimal patterns.
ffmpeg
Guide for using FFmpeg - a comprehensive multimedia framework for video/audio encoding, conversion, streaming, and filtering. Use when processing media files, converting formats, extracting audio, creating streams, applying filters, or optimizing video/audio quality.
ffmpeg-media
FFmpeg media processing. Video/audio transcoding, stream manipulation, and filter graphs.
mongodb_usage
This skill should be used when user asks to "query MongoDB", "show database collections", "get collection schema", "list MongoDB databases", "search records in MongoDB", or "check database indexes".
openai-usage
Report current OpenAI usage/rate-limit health from Codex ChatGPT limits.
ai-usage
Check AI CLI usage/quota for Claude Code, OpenAI Codex, Google Gemini CLI, and Z.AI. Use when user asks about remaining quota, usage limits, rate limits, or wants to check how much capacity is left.
bgo
Automates the complete Blender build-go workflow, from building and packaging your extension/add-on to removing old versions, installing, enabling, and launching Blender for quick testing and iteration.
mcp-create-declarative-agent
Skill converted from mcp-create-declarative-agent.prompt.md
MCP Architecture Expert
Design and implement Model Context Protocol servers for standardized AI-to-data integration with resources, tools, prompts, and security best practices
mathem-shopping
Automatiserar att logga in på Mathem.se, söka och lägga till varor från en lista eller recept, hantera ersättningar enligt policy och reservera leveranstid, men lämnar varukorgen redo för manuell checkout.
math-modeling
本技能应在用户要求"数学建模"、"建模比赛"、"数模论文"、"数学建模竞赛"、"建模分析"、"建模求解"或提及数学建模相关任务时使用。适用于全国大学生数学建模竞赛(CUMCM)、美国大学生数学建模竞赛(MCM/ICM)等各类数学建模比赛。
matchms
Mass spectrometry analysis. Process mzML/MGF/MSP, spectral similarity (cosine, modified cosine), metadata harmonization, compound ID, for metabolomics and MS data processing.