$npx -y skills add calesthio/OpenMontage --skill ffmpegVideo and audio processing with FFmpeg. Use for format conversion, resizing, compression, audio extraction, and preparing assets for Remotion. Triggers include converting GIF to MP4, resizing video, extracting audio, compressing files, or any media transformation task.
| 1 | # FFmpeg for Video Production |
| 2 | |
| 3 | FFmpeg is the essential tool for video/audio processing. This skill covers common operations for Remotion video projects. |
| 4 | |
| 5 | ## Quick Reference |
| 6 | |
| 7 | ### GIF to MP4 (Remotion-compatible) |
| 8 | |
| 9 | ```bash |
| 10 | ffmpeg -i input.gif -movflags faststart -pix_fmt yuv420p \ |
| 11 | -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" output.mp4 |
| 12 | ``` |
| 13 | |
| 14 | **Why these flags:** |
| 15 | - `-movflags faststart` - Moves metadata to start for web streaming |
| 16 | - `-pix_fmt yuv420p` - Ensures compatibility with most players |
| 17 | - `scale=trunc(...)` - Forces even dimensions (required by most codecs) |
| 18 | |
| 19 | ### Resize Video |
| 20 | |
| 21 | ```bash |
| 22 | # To 1920x1080 (maintain aspect ratio, add black bars) |
| 23 | ffmpeg -i input.mp4 -vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2" output.mp4 |
| 24 | |
| 25 | # To 1920x1080 (crop to fill) |
| 26 | ffmpeg -i input.mp4 -vf "scale=1920:1080:force_original_aspect_ratio=increase,crop=1920:1080" output.mp4 |
| 27 | |
| 28 | # Scale to width, auto height |
| 29 | ffmpeg -i input.mp4 -vf "scale=1280:-2" output.mp4 |
| 30 | ``` |
| 31 | |
| 32 | ### Compress Video |
| 33 | |
| 34 | ```bash |
| 35 | # Good quality, smaller file (CRF 23 is default, lower = better quality) |
| 36 | ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset medium -c:a aac -b:a 128k output.mp4 |
| 37 | |
| 38 | # Aggressive compression for web preview |
| 39 | ffmpeg -i input.mp4 -c:v libx264 -crf 28 -preset fast -c:a aac -b:a 96k output.mp4 |
| 40 | |
| 41 | # Target file size (e.g., ~10MB for 60s video = ~1.3Mbps) |
| 42 | ffmpeg -i input.mp4 -c:v libx264 -b:v 1300k -c:a aac -b:a 128k output.mp4 |
| 43 | ``` |
| 44 | |
| 45 | ### Extract Audio |
| 46 | |
| 47 | ```bash |
| 48 | # Extract to MP3 |
| 49 | ffmpeg -i input.mp4 -vn -acodec libmp3lame -q:a 2 output.mp3 |
| 50 | |
| 51 | # Extract to AAC |
| 52 | ffmpeg -i input.mp4 -vn -acodec aac -b:a 192k output.m4a |
| 53 | |
| 54 | # Extract to WAV (uncompressed) |
| 55 | ffmpeg -i input.mp4 -vn output.wav |
| 56 | ``` |
| 57 | |
| 58 | ### Convert Audio Formats |
| 59 | |
| 60 | ```bash |
| 61 | # M4A to MP3 (for ElevenLabs voice samples) |
| 62 | ffmpeg -i input.m4a -codec:a libmp3lame -qscale:a 2 output.mp3 |
| 63 | |
| 64 | # WAV to MP3 |
| 65 | ffmpeg -i input.wav -codec:a libmp3lame -b:a 192k output.mp3 |
| 66 | |
| 67 | # Adjust volume |
| 68 | ffmpeg -i input.mp3 -filter:a "volume=1.5" output.mp3 |
| 69 | ``` |
| 70 | |
| 71 | ### Trim/Cut Video |
| 72 | |
| 73 | ```bash |
| 74 | # Cut from timestamp to duration (recommended - reliable) |
| 75 | ffmpeg -i input.mp4 -ss 00:00:30 -t 00:00:15 -c:v libx264 -c:a aac output.mp4 |
| 76 | |
| 77 | # Cut from timestamp to timestamp |
| 78 | ffmpeg -i input.mp4 -ss 00:00:30 -to 00:00:45 -c:v libx264 -c:a aac output.mp4 |
| 79 | |
| 80 | # Stream copy (faster but may lose frames at cut points) |
| 81 | # Only use when source has frequent keyframes |
| 82 | ffmpeg -i input.mp4 -ss 00:00:30 -t 00:00:15 -c copy output.mp4 |
| 83 | ``` |
| 84 | |
| 85 | **Note:** Re-encoding is recommended for trimming. Stream copy (`-c copy`) can silently drop video if the seek point doesn't align with a keyframe. |
| 86 | |
| 87 | ### Speed Up / Slow Down |
| 88 | |
| 89 | ```bash |
| 90 | # 2x speed (video and audio) |
| 91 | ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" output.mp4 |
| 92 | |
| 93 | # 0.5x speed (slow motion) |
| 94 | ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=2.0*PTS[v];[0:a]atempo=0.5[a]" -map "[v]" -map "[a]" output.mp4 |
| 95 | |
| 96 | # Video only (no audio) |
| 97 | ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" -an output.mp4 |
| 98 | ``` |
| 99 | |
| 100 | ### Concatenate Videos |
| 101 | |
| 102 | ```bash |
| 103 | # Create file list |
| 104 | echo "file 'clip1.mp4'" > list.txt |
| 105 | echo "file 'clip2.mp4'" >> list.txt |
| 106 | echo "file 'clip3.mp4'" >> list.txt |
| 107 | |
| 108 | # Concatenate (same codec/resolution) |
| 109 | ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp4 |
| 110 | |
| 111 | # Concatenate with re-encoding (different sources) |
| 112 | ffmpeg -f concat -safe 0 -i list.txt -c:v libx264 -c:a aac output.mp4 |
| 113 | ``` |
| 114 | |
| 115 | ### Add Fade In/Out |
| 116 | |
| 117 | ```bash |
| 118 | # Fade in first 1 second, fade out last 1 second (30fps video) |
| 119 | ffmpeg -i input.mp4 -vf "fade=t=in:st=0:d=1,fade=t=out:st=9:d=1" -c:a copy output.mp4 |
| 120 | |
| 121 | # Audio fade |
| 122 | ffmpeg -i input.mp4 -af "afade=t=in:st=0:d=1,afade=t=out:st=9:d=1" -c:v copy output.mp4 |
| 123 | ``` |
| 124 | |
| 125 | ### Get Video Info |
| 126 | |
| 127 | ```bash |
| 128 | # Duration, resolution, codec info |
| 129 | ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4 |
| 130 | |
| 131 | # Full info |
| 132 | ffprobe -v quiet -print_format json -show_format -show_streams input.mp4 |
| 133 | ``` |
| 134 | |
| 135 | ## Remotion-Specific Patterns |
| 136 | |
| 137 | ### Video Speed Adjustment for Remotion |
| 138 | |
| 139 | **When to use FFmpeg vs Remotion `playbackRate`:** |
| 140 | |
| 141 | | Scenario | Use FFmpeg | Use Remotion | |
| 142 | |----------|------------|--------------| |
| 143 | | Constant speed (1.5x, 2x) | Either works | ✅ Simpler | |
| 144 | | Extreme speeds (>4x or <0.25x) | ✅ More reliable | May have issues | |
| 145 | | Variable speed (accelerate over time) | ✅ Pre-process | Complex workaround needed | |
| 146 | | Need perfect audio sync | ✅ Guaranteed | Usually fine | |
| 147 | | Demo needs to fit voiceover timing | ✅ Pre-calculate | Runtime adjustment | |
| 148 | |
| 149 | **Remotion limitation:** `playbackRate` must be constant. Dynamic interpolation like `playbackRate={interpolate(frame, [0, 100], [1, 5])}` won't work correctly because Remotion evaluates frames independently. |
| 150 | |
| 151 | ```bash |
| 152 | # Speed up |