FFmpeg
Process video and audio with correct codec selection, filtering, and encoding settings.
Iván
@ivangdavila
What This Skill Does
Command-line tool for processing video and audio files with precise control over codec selection, filtering, encoding settings, and container formats. Handles tasks like trimming, scaling, cropping, concatenation, subtitle handling, and hardware acceleration.
Replaces manual trial-and-error with GUI video editors by providing a single, scriptable tool that handles complex media processing workflows with correct codec and container choices.
When to Use It
- Trim a video clip with frame-accurate start and end times
- Convert a video file to a different container format without re-encoding
- Scale a video to a specific resolution while maintaining aspect ratio
- Extract audio track from a video file and save as a separate audio file
- Concatenate multiple video clips with matching codecs into a single file
- Burn subtitles into a video so they are always visible
Install
$ openclaw skills install @ivangdavila/ffmpegInput Seeking (Major Difference)
-ssBEFORE-i: fast seek, may be inaccurate—starts from nearest keyframe-ssAFTER-i: frame-accurate but slow—decodes from start- Combine both:
-ss 00:30:00 -i input.mp4 -ss 00:00:05—fast seek then accurate trim - For cutting, add
-avoid_negative_ts make_zeroto fix timestamp issues
Stream Selection
- Default: first video + first audio—may not be what you want
- Explicit selection:
-map 0:v:0 -map 0:a:1—first video, second audio - All streams of type:
-map 0:a—all audio streams - Copy specific:
-map 0 -c copy—all streams, no re-encoding - Exclude:
-map 0 -map -0:s—all except subtitles
Encoding Quality
- CRF (Constant Rate Factor): lower = better quality, larger file—18-23 typical for H.264
-preset: ultrafast to veryslow—slower = smaller file at same quality- Two-pass for target bitrate: first pass analyzes, second pass encodes
-crfand-b:vmutually exclusive—use one or the other
Container vs Codec
- Container (MP4, MKV, WebM): wrapper format holding streams
- Codec (H.264, VP9, AAC): compression algorithm for stream
- Not all codecs fit all containers—H.264 in MP4/MKV, not WebM; VP9 in WebM/MKV, not MP4
- Copy codec to new container:
-c copy—fast, no quality loss
Filter Syntax
- Simple:
-vf "scale=1280:720"—single filter chain - Complex:
-filter_complex "[0:v]scale=1280:720[scaled]"—named outputs for routing - Chain filters:
-vf "scale=1280:720,fps=30"—comma-separated - Filter order matters—scale before crop gives different result than crop before scale
Common Filters
- Scale:
scale=1280:720orscale=-1:720for auto-width maintaining aspect - Crop:
crop=640:480:100:50—width:height:x:y from top-left - FPS:
fps=30—change framerate - Trim:
trim=start=10:end=20,setpts=PTS-STARTPTS—setpts resets timestamps - Overlay:
overlay=10:10—position from top-left
Audio Processing
- Sample rate:
-ar 48000—standard for video - Channels:
-ac 2—stereo - Audio codec:
-c:a aac -b:a 192k—AAC at 192kbps - Normalize:
-filter:a loudnorm—EBU R128 loudness normalization - Extract audio:
-vn -c:a copy output.m4a—no video, copy audio
Concatenation
- Same codec/params: concat demuxer—
-f concat -safe 0 -i list.txt -c copy - Different formats: concat filter—
-filter_complex "[0:v][0:a][1:v][1:a]concat=n=2:v=1:a=1" - list.txt format:
file 'video1.mp4'per line—escape special characters - Different resolutions: scale/pad to match before concat filter
Subtitles
- Burn-in (hardcode):
-vf "subtitles=subs.srt"—cannot be turned off - Mux as stream:
-c:s mov_text(MP4) or-c:s srt(MKV)—user toggleable - From input:
-map 0:s—include subtitle streams - Extract:
-map 0:s:0 subs.srt—first subtitle to file
Hardware Acceleration
- Decode:
-hwaccel cudaor-hwaccel videotoolbox(macOS) - Encode:
-c:v h264_nvenc(NVIDIA),-c:v h264_videotoolbox(macOS) - Not always faster—setup overhead; benefits show on long videos
- Quality may differ—software encoding often produces better quality
Common Mistakes
- Forgetting
-c copywhen not re-encoding—defaults to re-encode, slow and lossy -ssafter-ifor long videos—takes forever seeking- Audio desync after cutting—use
-async 1or-af aresample=async=1 - Filter on stream copy—filters require re-encoding;
-c copy+-vf= error - Output extension doesn't set codec—
output.mp4without-c:vuses default, may not be H.264
Top skills in this category
SuperDesign
@mpociotExpert frontend design guidelines for creating beautiful, modern UIs. Use when building landing pages, dashboards, or any user interface.
Video Frames
@steipeteExtract frames or short clips from videos using ffmpeg.
Frontend Design
@michaelmonetizedCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when building web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
Remotion Video Toolkit
@shreefentsarComplete toolkit for programmatic video creation with Remotion + React. Covers animations, timing, rendering (CLI/Node.js/Lambda/Cloud Run), captions, 3D, charts, text effects, transitions, and media handling. Use when writing Remotion code, building video generation pipelines, or creating data-driven video templates.
Feishu Evolver Wrapper
@autogame-17(Depreciated: This skill is no longer maintained; its related functions have been absorbed by the Evolver main body.) Feishu-integrated wrapper for the capability-evolver. Manages the evolution loop lifecycle (start/stop/ensure), sends rich Feishu card reports, and provides...