ffmpeg-usage/SKILL.md
ffmpeg recipes and best practices: convert, concatenate, merge, resize, compress, GIF creation, audio extraction, subtitles, optimize for social platforms.
npx skillsauth add atxinsky/skills ffmpeg-usageInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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.
Use this Skill when the user requests:
Before using this skill, ensure ffmpeg is installed:
# macOS
brew install ffmpeg
# Ubuntu/Debian
sudo apt-get install ffmpeg
# Windows (with Chocolatey)
choco install ffmpeg
Verify installation:
ffmpeg -version
Convert between video formats with optimized settings.
MP4 to WebM:
ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 30 -b:v 0 -c:a libopus output.webm
MOV to MP4:
ffmpeg -i input.mov -c:v libx264 -c:a aac -strict experimental output.mp4
Any to MP4 (universal compatibility):
ffmpeg -i input.* -c:v libx264 -preset medium -crf 23 -c:a aac -b:a 128k output.mp4
Resize videos while maintaining aspect ratio.
Scale to 720p:
ffmpeg -i input.mp4 -vf scale=-1:720 -c:a copy output_720p.mp4
Scale to 1080p:
ffmpeg -i input.mp4 -vf scale=-1:1080 -c:a copy output_1080p.mp4
Scale to specific width (auto height):
ffmpeg -i input.mp4 -vf scale=1280:-1 -c:a copy output.mp4
Scale with padding (letterbox):
ffmpeg -i input.mp4 -vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2" output.mp4
Create high-quality GIFs from videos with optimized file size.
Basic GIF (10 fps):
ffmpeg -i input.mp4 -vf "fps=10,scale=480:-1:flags=lanczos" output.gif
High-quality GIF with palette:
# 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:
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
Extract, convert, and manipulate audio streams.
Extract audio to MP3:
ffmpeg -i input.mp4 -vn -acodec libmp3lame -q:a 2 output.mp3
Extract audio to WAV:
ffmpeg -i input.mp4 -vn -acodec pcm_s16le -ar 44100 -ac 2 output.wav
Convert audio format:
ffmpeg -i input.wav -c:a aac -b:a 192k output.m4a
Add background music:
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):
ffmpeg -i video.mp4 -i music.mp3 -filter_complex "[0:a][1:a]amix=inputs=2:duration=first" -c:v copy output.mp4
Trim, concatenate, and modify videos.
Trim video:
# 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)
# 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)
# 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)
# 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)Speed up/slow down:
# 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:
# 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
Add, extract, or burn subtitles.
Burn subtitles into video:
ffmpeg -i input.mp4 -vf subtitles=subtitles.srt output.mp4
Add soft subtitles:
ffmpeg -i input.mp4 -i subtitles.srt -c copy -c:s mov_text output.mp4
Extract subtitles:
ffmpeg -i input.mp4 -map 0:s:0 subtitles.srt
Extract frames as images.
Single frame at specific time:
ffmpeg -i input.mp4 -ss 00:00:05 -vframes 1 thumbnail.jpg
Multiple thumbnails:
# 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
Reduce file size while maintaining quality.
Compress video (balanced):
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset medium -c:a aac -b:a 128k output.mp4
High compression (smaller file):
ffmpeg -i input.mp4 -c:v libx264 -crf 28 -preset veryslow -c:a aac -b:a 96k output.mp4
Compress for web:
ffmpeg -i input.mp4 -c:v libx264 -preset medium -crf 23 -movflags +faststart -c:a aac -b:a 128k output.mp4
ffmpeg -i input.mp4 \
-c:v libx264 -preset slow -crf 18 \
-c:a aac -b:a 192k \
-pix_fmt yuv420p \
-movflags +faststart \
youtube.mp4
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
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
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
# 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
# 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
# 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
Always check input file first:
ffmpeg -i input.mp4
# Or use ffprobe for detailed info
ffprobe -v quiet -print_format json -show_format -show_streams input.mp4
Use -c copy when possible to avoid re-encoding:
ffmpeg -i input.mp4 -ss 00:01:00 -t 30 -c copy output.mp4
Preview before processing with -t flag:
# Test on first 10 seconds
ffmpeg -i input.mp4 -t 10 [other options] test.mp4
Use appropriate CRF values:
Add -movflags +faststart for web videos:
When using this skill, always:
When a user requests video/audio processing:
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.
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
development
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.
testing
Use when creating new skills, editing existing skills, or verifying skills work before deployment
development
Use when you have a spec or requirements for a multi-step task, before touching code
documentation
Create detailed implementation plan with bite-sized tasks