ffmpeg-cli
FFmpeg CLI Reference
Contents
- Dependencies
- Glossary of flags and filters
- Converting formats
- Resizing and padding
- Trim by time
- Verification and inspection
- Reference files
Dependencies
Verify ffmpeg is installed:
ffmpeg -version
Install if missing:
# macOS
brew install ffmpeg
# Ubuntu/Debian
sudo apt install ffmpeg
# Windows (scoop)
scoop install ffmpeg
Glossary of flags and filters
| Flag/Filter | Purpose |
|---|---|
-vf (also -filter:v) |
Video filter |
-af (also -filter:a) |
Audio filter |
-filter_complex |
Complex filter graph for multi-stream filtering |
[0] |
All streams from first input (0-based) |
[0:v] |
Video stream from first input |
[1:a] |
Audio stream from second input |
0:v:0 |
First input, first video stream |
0:a:1 |
First input, second audio stream |
[name] |
Named stream, used with -filter_complex |
-map [name] |
Select stream for output |
-y |
Auto-overwrite output files without confirmation |
Expression evaluations: if, lte, gte and more.
Converting formats
Remux MP4 to MKV (no re-encoding):
ffmpeg -i input.mp4 -c copy output.mkv
MKV and MP4 are both containers for H264/H265 video and AAC/MP3 audio. Video quality is determined by the codec, not the container. MKV supports multiple video streams; MP4 has wider device support.
Remux MP4 to MOV:
ffmpeg -i input.mp4 -c copy output.mov
Encode MP4 to AVI (re-encodes):
ffmpeg -i input.mp4 output.avi
Resizing and padding
Upscale to 1080x1920, preserve aspect ratio, black padding:
ffmpeg -i input.mp4 -vf "scale=w=1080:h=1920:force_original_aspect_ratio=decrease,pad=1080:1920:(ow-iw)/2:(oh-ih)/2:color=black,setsar=1:1" output.mp4
scale options:
force_original_aspect_ratio=decrease- auto-decrease output dimensions to fit aspect ratioforce_original_aspect_ratio=increase- auto-increase dimensionsscale=w=1080:h=-1- let ffmpeg pick correct height for aspect ratioscale=w=1080:h=-2- force dimensions divisible by 2
pad options:
pad=width:height:x:y:color- x:y is top-left corner position(ow-iw)/2:(oh-ih)/2centres the video; negative values also centre- pad reference
setsar=1:1 ensures 1:1 pixel aspect ratio. Prevents ffmpeg from compensating for ratio changes. setsar reference
Two scaled outputs from one input (horizontal + vertical with logo overlay):
ffmpeg -i input.mp4 -i logo.png \
-filter_complex "[0:v]split=2[s0][s1]; \
[s0]scale=w=1920:h=1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2:color=black,setsar=1:1[out1]; \
[s1]scale=w=720:h=1280:force_original_aspect_ratio=decrease,pad=720:1280:(ow-iw)/2:(oh-ih)/2:color=black,setsar=1:1[s2]; \
[s2][1]overlay=(main_w-overlay_w)/2:(main_w-overlay_w)/5[out2]" \
-map [out1] -map 0:a output_youtube.mp4 \
-map [out2] -map 0:a output_shorts.mp4
Trim by time
ffmpeg -i input.mp4 -ss 00:00:10 -to 00:00:25 output.mp4
For faster but less accurate trimming, see the Input/output seeking section in references/encoding-and-settings.md. For the -c copy trade-offs when trimming, see references/core-concepts.md.
Verification and inspection
List supported formats:
ffmpeg -formats
List supported codecs:
ffmpeg -codecs
ffprobe
ffprobe provides structured metadata about media files.
Show detailed stream information:
ffprobe -show_streams -i input.mp4
Verify moov atom position (faststart):
ffprobe -v trace -i input.mp4
Look for type:'moov' near the beginning of output to confirm faststart is applied.
Reference files
Load these on demand with the Read tool when the task requires deeper coverage.
| File | Topics |
|---|---|
references/core-concepts.md |
-c copy (remux vs transcode), input/output seeking, encoding quick ref (H264/H265/VP9 CRF ranges), GPU acceleration overview, format=yuv420p, -movflags +faststart |
references/audio-processing.md |
Replace audio, extract audio, mix audio, combine MP3 tracks, crossfade, change audio format, merge and normalise |
references/advanced-editing.md |
Playback speed, FPS change, jump cuts, video cropping for social, drawtext overlay, subtitles (burn/embed/extract), combine media (overlay, logo, background, concat intro/main/outro, vstack) |
references/asset-generation.md |
Image to video, slideshow with fade, Ken Burns (zoompan), GIFs, video compilation with fades, thumbnails (single/multiple/scene), image thumbnails, storyboards (scene tile/keyframe/Nth frame) |
references/encoding-and-settings.md |
Optimised daily command, H264 (libx264) deep-dive, H265 (libx265) Apple compat, VP9 (libvpx-vp9) constant quality, 1-pass vs 2-pass, -c copy detailed, seeking detailed, GPU detailed (Nvidia/Intel/AMD) |
More from henkisdabro/wookstar-claude-plugins
google-ads-scripts
Expert guidance for Google Ads Script development including AdsApp API, campaign management, ad groups, keywords, bidding strategies, performance reporting, budget management, automated rules, and optimization patterns. Use when automating Google Ads campaigns, managing keywords and bids, creating performance reports, implementing automated rules, optimizing ad spend, working with campaign budgets, monitoring quality scores, tracking conversions, pausing low-performing keywords, adjusting bids based on ROAS, or building Google Ads automation scripts. Covers campaign operations, keyword targeting, bid optimization, conversion tracking, error handling, and JavaScript-based automation in Google Ads editor.
77timezone-tools
Get current time in any timezone and convert times between timezones. Use when working with time, dates, timezones, scheduling across regions, or when user mentions specific cities/regions for time queries. Supports IANA timezone names.
62shopify-developer
Complete Shopify development reference for Liquid templating, theme development (OS 2.0), GraphQL Admin API, Storefront API, custom app development, Shopify Functions, Hydrogen, performance optimisation, and debugging. Use when working with .liquid files, creating theme sections and blocks, writing GraphQL queries or mutations for Shopify, building Shopify apps with CLI and Polaris, implementing cart operations via Ajax API, optimising Core Web Vitals for Shopify stores, debugging Liquid or API errors, configuring settings_schema.json, accessing Shopify objects (product, collection, cart, customer), using Liquid filters, creating app extensions, working with webhooks, migrating from Scripts to Functions, or building headless storefronts with Hydrogen and React Router 7. Covers API version 2026-01.
28google-analytics
Comprehensive Google Analytics 4 guide covering property setup, events, custom events, recommended events, custom dimensions, user tracking, audiences, reporting, BigQuery integration, gtag.js implementation, GTM integration, Measurement Protocol, DebugView, privacy compliance, and data management. Use when working with GA4 implementation, tracking, analysis, or any GA4-related tasks.
24google-tagmanager
Comprehensive Google Tag Manager guide covering container setup, tags, triggers, variables, data layer, debugging, custom templates, and API automation. Use when working with GTM implementation, configuration, optimisation, troubleshooting, or any GTM-related tasks.
23tampermonkey
Write and debug Tampermonkey userscripts for browser automation, page modification, and web enhancement. Use whenever the user mentions userscripts, Tampermonkey, Greasemonkey, Violentmonkey, or wants to write a script that runs on a website - even if they don't say 'userscript' explicitly. Also trigger for: injecting JavaScript or CSS into web pages, modifying website behaviour, hiding page elements, form auto-fill, scraping page data, intercepting requests, detecting URL changes in SPAs, adding keyboard shortcuts to websites, tab audio control, or TypeScript userscripts. Covers all header tags (@match, @grant, @require, @run-in), GM_* synchronous APIs, GM.* promise-based APIs (recommended for new scripts), batch storage (GM.getValues/setValues v5.3+), binary data support (v5.4+), TypeScript setup via @types/tampermonkey, security sandboxing, and cross-browser compatibility (Chrome, Firefox, Edge). Do NOT use for Selenium/Puppeteer automation, browser extensions (WebExtensions/MV3), or server-side scripts.
23