
Ffmpeg Toolkit
- 39 installs
- 1 repo stars
- Updated July 11, 2026
- simonlee2/claude-plugins
Helps with ai & agent building tasks.
About
ffmpeg-toolkit is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted coding.
- ffmpeg-toolkit
- AI & Agent Building
- AI-coding skill
Ffmpeg Toolkit by the numbers
- 39 all-time installs (skills.sh)
- Ranked #8,347 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/simonlee2/claude-plugins --skill ffmpeg-toolkitAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 39 |
|---|---|
| repo stars | ★ 1 |
| Last updated | July 11, 2026 |
| Repository | simonlee2/claude-plugins ↗ |
What it does
Helps with ai & agent building tasks.
Files
FFmpeg Toolkit
Comprehensive guide for video and audio processing with ffmpeg.
Overview
This skill provides guidance on using ffmpeg for common video and audio operations. ffmpeg is a powerful command-line tool for processing multimedia files - converting formats, trimming, resizing, extracting audio, creating GIFs, and much more.
Core Principles
Always Use These Flags
-hide_banner- Suppress ffmpeg version info for cleaner output-y- Overwrite output file without asking (for automation)
When to Use -c copy (Stream Copy)
Use -c copy when you want to:
- Preserve original quality (no re-encoding)
- Process quickly (10-100x faster than re-encoding)
- Keep file size similar to source
Limitation: Stream copy cannot change codec, resolution, or apply filters.
When to Re-encode
Re-encode when you need to:
- Change resolution or aspect ratio
- Apply filters (crop, rotate, overlay)
- Change codec (e.g., HEVC to H.264)
- Adjust quality/bitrate
- Frame-accurate trimming
Common Operations
1. Format Conversion
Basic conversion (re-encodes):
ffmpeg -hide_banner -i input.mkv output.mp4Lossless remux (no re-encoding):
ffmpeg -hide_banner -i input.mkv -c copy output.mp4Convert to web-optimized MP4:
ffmpeg -hide_banner -i input.mov -c:v libx264 -crf 23 -c:a aac -movflags faststart output.mp42. Trimming/Cutting
Fast trim (no re-encoding, may have keyframe issues):
ffmpeg -hide_banner -ss 00:01:30 -i input.mp4 -t 00:00:30 -c copy output.mp4-ss 00:01:30- Start at 1 minute 30 seconds-t 00:00:30- Duration of 30 seconds
Frame-accurate trim (requires re-encoding):
ffmpeg -hide_banner -i input.mp4 -ss 00:01:30 -t 00:00:30 -c:v libx264 -c:a aac output.mp4Trim to end of file:
ffmpeg -hide_banner -ss 00:05:00 -i input.mp4 -c copy output.mp43. Audio Operations
Extract audio to MP3:
ffmpeg -hide_banner -i video.mp4 -vn -c:a libmp3lame -q:a 2 audio.mp3Extract audio to WAV (lossless):
ffmpeg -hide_banner -i video.mp4 -vn audio.wavRemove audio from video:
ffmpeg -hide_banner -i input.mp4 -an -c:v copy output.mp4Add audio to video:
ffmpeg -hide_banner -i video.mp4 -i audio.mp3 -c:v copy -c:a aac -map 0:v -map 1:a output.mp4Replace audio in video:
ffmpeg -hide_banner -i video.mp4 -i new_audio.mp3 -c:v copy -c:a aac -map 0:v -map 1:a -shortest output.mp44. Resizing/Scaling
Scale to specific resolution:
ffmpeg -hide_banner -i input.mp4 -vf "scale=1920:1080" -c:a copy output.mp4Scale maintaining aspect ratio (width 1280, auto height):
ffmpeg -hide_banner -i input.mp4 -vf "scale=1280:-1" -c:a copy output.mp4Scale to fit within bounds (won't exceed 1920x1080):
ffmpeg -hide_banner -i input.mp4 -vf "scale='min(1920,iw)':'min(1080,ih)'" -c:a copy output.mp45. Compression
Constant Rate Factor (CRF) - Recommended:
ffmpeg -hide_banner -i input.mp4 -c:v libx264 -crf 23 -c:a aac output.mp4- CRF 18: Visually lossless
- CRF 23: Default, good balance
- CRF 28: Smaller file, lower quality
Target bitrate:
ffmpeg -hide_banner -i input.mp4 -c:v libx264 -b:v 2M -c:a aac -b:a 128k output.mp4Two-pass encoding (best quality for target size):
ffmpeg -hide_banner -i input.mp4 -c:v libx264 -b:v 2M -pass 1 -f null /dev/null
ffmpeg -hide_banner -i input.mp4 -c:v libx264 -b:v 2M -pass 2 output.mp46. Creating GIFs
Basic GIF:
ffmpeg -hide_banner -i input.mp4 -vf "fps=10,scale=480:-1" output.gifHigh-quality GIF with palette:
ffmpeg -hide_banner -i input.mp4 -vf "fps=10,scale=480:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" output.gifGIF from specific section:
ffmpeg -hide_banner -ss 00:00:05 -t 3 -i input.mp4 -vf "fps=15,scale=320:-1:flags=lanczos" output.gif7. Combining Videos
Concatenate videos (same codec):
First create a file list (videos.txt):
file 'video1.mp4'
file 'video2.mp4'
file 'video3.mp4'Then concatenate:
ffmpeg -hide_banner -f concat -safe 0 -i videos.txt -c copy output.mp4Concatenate with re-encoding (different codecs/resolutions):
ffmpeg -hide_banner -f concat -safe 0 -i videos.txt -c:v libx264 -c:a aac output.mp48. Rotation
Rotate 90° clockwise:
ffmpeg -hide_banner -i input.mp4 -vf "transpose=1" output.mp4Transpose values:
0- 90° counterclockwise + vertical flip1- 90° clockwise2- 90° counterclockwise3- 90° clockwise + vertical flip
Rotate 180°:
ffmpeg -hide_banner -i input.mp4 -vf "transpose=1,transpose=1" output.mp49. Cropping
Crop to specific dimensions:
ffmpeg -hide_banner -i input.mp4 -vf "crop=640:480:100:50" output.mp4Format: crop=width:height:x:y
Crop center square:
ffmpeg -hide_banner -i input.mp4 -vf "crop=min(iw\,ih):min(iw\,ih)" output.mp410. Speed Adjustment
Speed up video 2x:
ffmpeg -hide_banner -i input.mp4 -vf "setpts=0.5*PTS" -af "atempo=2.0" output.mp4Slow down video 0.5x:
ffmpeg -hide_banner -i input.mp4 -vf "setpts=2*PTS" -af "atempo=0.5" output.mp4Speed up without audio:
ffmpeg -hide_banner -i input.mp4 -vf "setpts=0.5*PTS" -an output.mp4Advanced Operations
Add Subtitles
Burn subtitles into video:
ffmpeg -hide_banner -i input.mp4 -vf "subtitles=subs.srt" output.mp4Burn ASS subtitles (styled):
ffmpeg -hide_banner -i input.mp4 -vf "ass=subs.ass" output.mp4Add Watermark/Overlay
Image overlay (top-right corner):
ffmpeg -hide_banner -i input.mp4 -i logo.png -filter_complex "overlay=W-w-10:10" output.mp4Extract Frames
Extract all frames:
ffmpeg -hide_banner -i input.mp4 frame_%04d.pngExtract 1 frame per second:
ffmpeg -hide_banner -i input.mp4 -vf "fps=1" frame_%04d.pngExtract single frame at timestamp:
ffmpeg -hide_banner -ss 00:00:10 -i input.mp4 -frames:v 1 thumbnail.pngCreate Video from Images
Images to video:
ffmpeg -hide_banner -framerate 30 -i frame_%04d.png -c:v libx264 -pix_fmt yuv420p output.mp4Change Metadata
Set title:
ffmpeg -hide_banner -i input.mp4 -c copy -metadata title="My Video" output.mp4Remove all metadata:
ffmpeg -hide_banner -i input.mp4 -c copy -map_metadata -1 output.mp4Hardware Acceleration (NVIDIA)
Encode with NVENC:
ffmpeg -hide_banner -i input.mp4 -c:v h264_nvenc -preset fast -b:v 5M output.mp4Decode and encode with GPU:
ffmpeg -hide_banner -hwaccel cuda -i input.mp4 -c:v h264_nvenc output.mp4Quick Reference
| Task | Command |
|---|---|
| Get info | ffmpeg -i input.mp4 |
| Convert format | ffmpeg -i in.mkv out.mp4 |
| Remux (fast) | ffmpeg -i in.mkv -c copy out.mp4 |
| Trim | ffmpeg -ss 00:01:00 -t 30 -i in.mp4 -c copy out.mp4 |
| Extract audio | ffmpeg -i in.mp4 -vn out.mp3 |
| Remove audio | ffmpeg -i in.mp4 -an -c:v copy out.mp4 |
| Scale | ffmpeg -i in.mp4 -vf "scale=1280:-1" out.mp4 |
| Compress | ffmpeg -i in.mp4 -crf 28 out.mp4 |
| To GIF | ffmpeg -i in.mp4 -vf "fps=10,scale=320:-1" out.gif |
| Rotate 90° | ffmpeg -i in.mp4 -vf "transpose=1" out.mp4 |
Best Practices
1. Always test on a short clip first before processing large files 2. Use `-c copy` when possible for speed and quality preservation 3. Add `-movflags faststart` for web-optimized MP4s 4. Use CRF for quality-based encoding instead of fixed bitrate 5. Check input info first with ffmpeg -i input.mp4 to understand source 6. Use two-pass encoding when targeting specific file size
Common Pitfalls
- Audio/video sync issues after trim: Use re-encoding instead of
-c copy - Black frames at start: Add
-avoid_negative_ts make_zero - Incompatible codec in container: Check container format supports codec
- GIF too large: Reduce FPS, scale down, or shorten duration
Additional Resources
For detailed command reference, see references/ffmpeg-commands.md.
FFmpeg Command Reference
Detailed reference for ffmpeg flags, options, and advanced usage.
Command Structure
ffmpeg [global_options] {[input_options] -i input} ... {[output_options] output} ...Global Options
| Option | Description |
|---|---|
-hide_banner | Suppress printing banner |
-y | Overwrite output without asking |
-n | Never overwrite output |
-v quiet | Suppress all output except errors |
-stats | Print encoding progress/statistics |
Input Options
| Option | Description | Example |
|---|---|---|
-ss | Seek to position | -ss 00:01:30 or -ss 90 |
-t | Duration to process | -t 00:00:30 or -t 30 |
-to | Stop at position | -to 00:02:00 |
-r | Set input framerate | -r 30 |
-f | Force input format | -f concat |
Position Notes
-ssbefore-i: Fast seek (may be inaccurate)-ssafter-i: Slow seek (frame-accurate)- Use seconds or HH:MM:SS.ms format
Output Options
Video Codec Options
| Option | Description | Example |
|---|---|---|
-c:v | Video codec | -c:v libx264 |
-c:v copy | Copy video stream | No re-encoding |
-vn | No video | Discard video |
-vf | Video filter | -vf "scale=1280:-1" |
Common Video Codecs
| Codec | Library | Notes |
|---|---|---|
| H.264 | libx264 | Most compatible |
| H.265/HEVC | libx265 | Better compression |
| VP9 | libvpx-vp9 | WebM format |
| AV1 | libaom-av1 | Best compression, slow |
| ProRes | prores_ks | Editing codec |
Audio Codec Options
| Option | Description | Example |
|---|---|---|
-c:a | Audio codec | -c:a aac |
-c:a copy | Copy audio stream | No re-encoding |
-an | No audio | Discard audio |
-af | Audio filter | -af "volume=2" |
-b:a | Audio bitrate | -b:a 192k |
Common Audio Codecs
| Codec | Library | Notes |
|---|---|---|
| AAC | aac | Default MP4 audio |
| MP3 | libmp3lame | Universal support |
| Opus | libopus | Best quality/size |
| FLAC | flac | Lossless |
| PCM | pcm_s16le | Uncompressed |
Quality Control
CRF (Constant Rate Factor)
H.264/libx264:
-c:v libx264 -crf 23- Range: 0-51 (0 = lossless, 51 = worst)
- 18: Visually lossless
- 23: Default
- 28: Low quality, small file
H.265/libx265:
-c:v libx265 -crf 28- Range: 0-51
- 28: Equivalent to x264 CRF 23
VP9:
-c:v libvpx-vp9 -crf 31 -b:v 0- Range: 0-63
- 31: Good quality
- Must set
-b:v 0to use CRF mode
Presets (Speed vs Compression)
-preset ultrafast # Fastest, largest file
-preset superfast
-preset veryfast
-preset faster
-preset fast
-preset medium # Default
-preset slow
-preset slower
-preset veryslow # Slowest, smallest fileBitrate Control
| Mode | Flags | Notes |
|---|---|---|
| CBR | -b:v 5M | Constant bitrate |
| VBR | -crf 23 | Variable, quality-based |
| Capped VBR | -crf 23 -maxrate 5M -bufsize 10M | Quality with cap |
Video Filters (-vf)
Scaling
scale=1920:1080 # Exact size
scale=1280:-1 # Width 1280, auto height
scale=-1:720 # Auto width, height 720
scale=iw/2:ih/2 # Half size
scale='min(1920,iw)':'-1' # Max width 1920Cropping
crop=640:480:100:50 # width:height:x:y
crop=in_w:in_h-100 # Remove 100px from bottom
crop=iw:ih-100:0:0 # Remove 100px from bottomPadding
pad=1920:1080:(ow-iw)/2:(oh-ih)/2 # Center in 1920x1080
pad=iw:ih+100:0:50:black # Add 50px top/bottomRotation
transpose=0 # 90° CCW + vertical flip
transpose=1 # 90° clockwise
transpose=2 # 90° counterclockwise
transpose=3 # 90° CW + vertical flip
hflip # Horizontal flip
vflip # Vertical flipSpeed/Tempo
setpts=0.5*PTS # 2x speed (video)
setpts=2*PTS # 0.5x speed (video)Color/Effects
eq=brightness=0.1:saturation=1.5 # Adjust brightness/saturation
colorbalance=rs=0.3 # Color correction
curves=preset=lighter # Preset curves
hue=h=90 # Rotate hueText Overlay
drawtext=text='Hello':fontsize=24:fontcolor=white:x=10:y=10
drawtext=textfile=text.txt:reload=1:fontsize=24:y=h-th-10Timestamps
drawtext=text='%{pts\:hms}':fontsize=24:x=10:y=10Audio Filters (-af)
Volume
volume=2 # Double volume
volume=0.5 # Half volume
volume=10dB # Increase by 10dB
loudnorm # Normalize loudnessSpeed/Tempo
atempo=2.0 # 2x speed (0.5-2.0 range)
atempo=2.0,atempo=2.0 # 4x speed (chain for >2x)Fade
afade=t=in:st=0:d=3 # Fade in 3s at start
afade=t=out:st=57:d=3 # Fade out starting at 57sChannels
pan=mono|c0=0.5*c0+0.5*c1 # Convert to mono
channelsplit # Split stereo to two monoStream Selection (-map)
-map 0 # All streams from first input
-map 0:v # All video from first input
-map 0:a # All audio from first input
-map 0:v:0 # First video stream from first input
-map 0:a:1 # Second audio stream from first input
-map 1:a # All audio from second inputExamples
Replace audio:
ffmpeg -i video.mp4 -i audio.mp3 -map 0:v -map 1:a -c copy output.mp4Keep video, remove audio:
ffmpeg -i input.mp4 -map 0:v -c copy output.mp4Select specific streams:
ffmpeg -i input.mkv -map 0:v:0 -map 0:a:1 -c copy output.mp4Concatenation
Concat Demuxer (Same Codec)
Create files.txt:
file 'video1.mp4'
file 'video2.mp4'ffmpeg -f concat -safe 0 -i files.txt -c copy output.mp4Concat Filter (Different Codecs)
ffmpeg -i v1.mp4 -i v2.mp4 -filter_complex "[0:v][0:a][1:v][1:a]concat=n=2:v=1:a=1" output.mp4Hardware Acceleration
NVIDIA (NVENC/NVDEC)
Decode with GPU:
-hwaccel cuda
-hwaccel_output_format cudaEncode with GPU:
-c:v h264_nvenc
-c:v hevc_nvencFull GPU pipeline:
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input.mp4 -c:v h264_nvenc output.mp4Intel QuickSync
-c:v h264_qsv
-c:v hevc_qsvApple VideoToolbox
-c:v h264_videotoolbox
-c:v hevc_videotoolboxContainer Formats
| Extension | Format | Video Codecs | Audio Codecs |
|---|---|---|---|
| .mp4 | MPEG-4 | H.264, H.265 | AAC, MP3 |
| .mkv | Matroska | Any | Any |
| .webm | WebM | VP8, VP9, AV1 | Vorbis, Opus |
| .mov | QuickTime | H.264, ProRes | AAC, PCM |
| .avi | AVI | Many | Many |
| .gif | GIF | GIF | None |
Useful Flags
| Flag | Description |
|---|---|
-movflags faststart | Web-optimized MP4 |
-pix_fmt yuv420p | Compatibility pixel format |
-shortest | End when shortest input ends |
-avoid_negative_ts make_zero | Fix timestamps |
-vsync vfr | Variable framerate |
-async 1 | Sync audio to video |
Getting Information
Full info:
ffmpeg -i input.mp4JSON output:
ffprobe -v quiet -print_format json -show_format -show_streams input.mp4Duration only:
ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4Resolution:
ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 input.mp4Common Patterns
Web-Ready MP4
ffmpeg -i input.mov -c:v libx264 -crf 23 -preset medium -c:a aac -b:a 128k -movflags faststart -pix_fmt yuv420p output.mp4Thumbnail Generation
ffmpeg -i input.mp4 -ss 00:00:05 -frames:v 1 -q:v 2 thumbnail.jpgPreview/Proxy
ffmpeg -i input.mp4 -vf "scale=640:-1" -c:v libx264 -crf 28 -preset veryfast -c:a aac -b:a 64k proxy.mp4Audio Normalization
ffmpeg -i input.mp4 -af loudnorm -c:v copy output.mp4Batch Processing
for f in *.mp4; do ffmpeg -i "$f" -c:v libx264 -crf 23 "converted_$f"; doneError Solutions
| Error | Solution |
|---|---|
| "Non-monotonous DTS" | Add -fflags +genpts |
| "Discarding NAL unit" | Re-encode video |
| "Invalid data found" | Check file integrity |
| "Audio sync issues" | Use -async 1 or re-encode |
| "Avi header overlong" | Add -max_muxing_queue_size 1024 |
Resources
- Official documentation: https://ffmpeg.org/documentation.html
- FFmpeg wiki: https://trac.ffmpeg.org/wiki
- CLI guidelines: https://clig.dev/