$npx -y skills add henkisdabro/wookstar-claude-plugins --skill ffmpeg-cliFFmpeg CLI reference for video and audio processing, format conversion, filtering, and media automation. Use when converting video formats, resizing or cropping video, trimming by time, replacing or extracting audio, mixing audio tracks, overlaying text or images, burning subtitl
| 1 | # FFmpeg CLI Reference |
| 2 | |
| 3 | ## Contents |
| 4 | |
| 5 | - [Dependencies](#dependencies) |
| 6 | - [Glossary of flags and filters](#glossary-of-flags-and-filters) |
| 7 | - [Converting formats](#converting-formats) |
| 8 | - [Resizing and padding](#resizing-and-padding) |
| 9 | - [Trim by time](#trim-by-time) |
| 10 | - [Verification and inspection](#verification-and-inspection) |
| 11 | - [Reference files](#reference-files) |
| 12 | |
| 13 | ## Dependencies |
| 14 | |
| 15 | Verify ffmpeg is installed: |
| 16 | |
| 17 | ```sh |
| 18 | ffmpeg -version |
| 19 | ``` |
| 20 | |
| 21 | Install if missing: |
| 22 | |
| 23 | ```sh |
| 24 | # macOS |
| 25 | brew install ffmpeg |
| 26 | |
| 27 | # Ubuntu/Debian |
| 28 | sudo apt install ffmpeg |
| 29 | |
| 30 | # Windows (scoop) |
| 31 | scoop install ffmpeg |
| 32 | ``` |
| 33 | |
| 34 | ## Glossary of flags and filters |
| 35 | |
| 36 | [Filtering reference](https://ffmpeg.org/ffmpeg-filters.html#Filtering-Introduction) |
| 37 | |
| 38 | | Flag/Filter | Purpose | |
| 39 | |---|---| |
| 40 | | `-vf` (also `-filter:v`) | Video filter | |
| 41 | | `-af` (also `-filter:a`) | Audio filter | |
| 42 | | `-filter_complex` | Complex filter graph for multi-stream filtering | |
| 43 | | `[0]` | All streams from first input (0-based) | |
| 44 | | `[0:v]` | Video stream from first input | |
| 45 | | `[1:a]` | Audio stream from second input | |
| 46 | | `0:v:0` | First input, first video stream | |
| 47 | | `0:a:1` | First input, second audio stream | |
| 48 | | `[name]` | Named stream, used with `-filter_complex` | |
| 49 | | `-map [name]` | [Select stream for output](https://trac.ffmpeg.org/wiki/Map) | |
| 50 | | `-y` | Auto-overwrite output files without confirmation | |
| 51 | |
| 52 | [Expression evaluations](https://ffmpeg.org/ffmpeg-all.html#Expression-Evaluation): `if`, `lte`, `gte` and more. |
| 53 | |
| 54 | ## Converting formats |
| 55 | |
| 56 | Remux MP4 to MKV (no re-encoding): |
| 57 | |
| 58 | ```sh |
| 59 | ffmpeg -i input.mp4 -c copy output.mkv |
| 60 | ``` |
| 61 | |
| 62 | 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. |
| 63 | |
| 64 | Remux MP4 to MOV: |
| 65 | |
| 66 | ```sh |
| 67 | ffmpeg -i input.mp4 -c copy output.mov |
| 68 | ``` |
| 69 | |
| 70 | Encode MP4 to AVI (re-encodes): |
| 71 | |
| 72 | ```sh |
| 73 | ffmpeg -i input.mp4 output.avi |
| 74 | ``` |
| 75 | |
| 76 | ## Resizing and padding |
| 77 | |
| 78 | Upscale to 1080x1920, preserve aspect ratio, black padding: |
| 79 | |
| 80 | ```sh |
| 81 | 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 |
| 82 | ``` |
| 83 | |
| 84 | **scale** options: |
| 85 | |
| 86 | - `force_original_aspect_ratio=decrease` - auto-decrease output dimensions to fit aspect ratio |
| 87 | - `force_original_aspect_ratio=increase` - auto-increase dimensions |
| 88 | - `scale=w=1080:h=-1` - let ffmpeg pick correct height for aspect ratio |
| 89 | - `scale=w=1080:h=-2` - force dimensions divisible by 2 |
| 90 | |
| 91 | [scale reference](https://trac.ffmpeg.org/wiki/Scaling) |
| 92 | |
| 93 | **pad** options: |
| 94 | |
| 95 | - `pad=width:height:x:y:color` - x:y is top-left corner position |
| 96 | - `(ow-iw)/2:(oh-ih)/2` centres the video; negative values also centre |
| 97 | - [pad reference](https://ffmpeg.org/ffmpeg-filters.html#pad) |
| 98 | |
| 99 | **setsar=1:1** ensures 1:1 pixel aspect ratio. Prevents ffmpeg from compensating for ratio changes. [setsar reference](https://ffmpeg.org/ffmpeg-filters.html#setdar_002c-setsar) |
| 100 | |
| 101 | Two scaled outputs from one input (horizontal + vertical with logo overlay): |
| 102 | |
| 103 | ```sh |
| 104 | ffmpeg -i input.mp4 -i logo.png \ |
| 105 | -filter_complex "[0:v]split=2[s0][s1]; \ |
| 106 | [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]; \ |
| 107 | [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]; \ |
| 108 | [s2][1]overlay=(main_w-overlay_w)/2:(main_w-overlay_w)/5[out2]" \ |
| 109 | -map [out1] -map 0:a output_youtube.mp4 \ |
| 110 | -map [out2] -map 0:a output_shorts.mp4 |
| 111 | ``` |
| 112 | |
| 113 | ## Trim by time |
| 114 | |
| 115 | ```sh |
| 116 | ffmpeg -i input.mp4 -ss 00:00:10 -to 00:00:25 output.mp4 |
| 117 | ``` |
| 118 | |
| 119 | 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`. |
| 120 | |
| 121 | ## Verification and inspection |
| 122 | |
| 123 | List supported formats: |
| 124 | |
| 125 | ```sh |
| 126 | ffmpeg -formats |
| 127 | ``` |
| 128 | |
| 129 | List supported codecs: |
| 130 | |
| 131 | ```sh |
| 132 | ffmpeg -codecs |
| 133 | ``` |
| 134 | |
| 135 | ### ffprobe |
| 136 | |
| 137 | [ffprobe](https://ffmpeg.org/ffprobe.html) provides structured metadata about media files. |
| 138 | |
| 139 | Show detailed stream information: |
| 140 | |
| 141 | ```sh |
| 142 | ffprobe -show_streams -i input.mp4 |
| 143 | ``` |
| 144 | |
| 145 | Verify moov atom position (faststart): |
| 146 | |
| 147 | ```sh |
| 148 | ffprobe -v trace |