home / skills / benchflow-ai / skillsbench / ffmpeg-video-filters

This skill helps you apply FFmpeg video filters for scaling, cropping, overlays, speed changes, and visual effects to enhance media.

npx playbooks add skill benchflow-ai/skillsbench --skill ffmpeg-video-filters

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
3.4 KB
---
name: FFmpeg Video Filters
description: Apply video filters - scale, crop, watermark, speed, blur, and visual effects
---

# FFmpeg Video Filters Skill

Apply video filters for scaling, cropping, watermarks, speed changes, and visual effects.

## When to Use

- Resize videos
- Crop video frames
- Add watermarks or overlays
- Change playback speed
- Apply blur or other effects
- Adjust brightness/contrast

## Scaling

```bash
# Scale to 720p (maintain aspect ratio)
ffmpeg -i input.mp4 -vf scale=-2:720 output.mp4

# Scale to specific width (maintain aspect ratio)
ffmpeg -i input.mp4 -vf scale=1280:-2 output.mp4

# Scale to exact dimensions (may distort)
ffmpeg -i input.mp4 -vf scale=1920:1080 output.mp4

# Scale with algorithm
ffmpeg -i input.mp4 -vf scale=1280:720:flags=lanczos output.mp4
```

## Cropping

```bash
# Crop to 16:9 from center
ffmpeg -i input.mp4 -vf "crop=1920:1080" output.mp4

# Crop with offset (x:y:width:height)
ffmpeg -i input.mp4 -vf "crop=1920:1080:0:0" output.mp4

# Crop from specific position
ffmpeg -i input.mp4 -vf "crop=800:600:100:50" output.mp4
```

## Watermarks and Overlays

```bash
# Add image watermark (top-left)
ffmpeg -i input.mp4 -i logo.png \
  -filter_complex "overlay=10:10" output.mp4

# Bottom-right watermark
ffmpeg -i input.mp4 -i logo.png \
  -filter_complex "overlay=W-w-10:H-h-10" output.mp4

# Center watermark
ffmpeg -i input.mp4 -i logo.png \
  -filter_complex "overlay=(W-w)/2:(H-h)/2" output.mp4
```

## Speed Changes

```bash
# Speed up 2x
ffmpeg -i input.mp4 -vf "setpts=0.5*PTS" -af "atempo=2.0" output.mp4

# Slow down 0.5x
ffmpeg -i input.mp4 -vf "setpts=2.0*PTS" -af "atempo=0.5" output.mp4

# Speed up video only (no audio)
ffmpeg -i input.mp4 -vf "setpts=0.5*PTS" -an output.mp4
```

## Blur Effects

```bash
# Blur entire video
ffmpeg -i input.mp4 -vf "boxblur=10:5" output.mp4

# Blur specific region (coordinates x:y:w:h)
ffmpeg -i input.mp4 -vf "boxblur=10:5:x=100:y=100:w=200:h=200" output.mp4

# Gaussian blur
ffmpeg -i input.mp4 -vf "gblur=sigma=5" output.mp4
```

## Brightness and Contrast

```bash
# Adjust brightness and contrast
ffmpeg -i input.mp4 -vf "eq=brightness=0.1:contrast=1.2" output.mp4

# Increase brightness
ffmpeg -i input.mp4 -vf "eq=brightness=0.2" output.mp4

# Adjust saturation
ffmpeg -i input.mp4 -vf "eq=saturation=1.5" output.mp4
```

## Rotation

```bash
# Rotate 90 degrees clockwise
ffmpeg -i input.mp4 -vf "transpose=1" output.mp4

# Rotate 90 degrees counter-clockwise
ffmpeg -i input.mp4 -vf "transpose=2" output.mp4

# Rotate 180 degrees
ffmpeg -i input.mp4 -vf "transpose=1,transpose=1" output.mp4
```

## Multiple Filters

```bash
# Chain multiple filters
ffmpeg -i input.mp4 -vf "scale=1280:720,crop=800:600:100:50" output.mp4

# Complex filter chain
ffmpeg -i input.mp4 -i logo.png \
  -filter_complex "[0:v]scale=1280:720[scaled];[scaled][1:v]overlay=10:10" \
  output.mp4
```

## Fade Effects

```bash
# Fade in (first 2 seconds)
ffmpeg -i input.mp4 -vf "fade=t=in:st=0:d=2" output.mp4

# Fade out (last 2 seconds)
ffmpeg -i input.mp4 -vf "fade=t=out:st=10:d=2" output.mp4

# Fade in and out
ffmpeg -i input.mp4 -vf "fade=t=in:st=0:d=2,fade=t=out:st=8:d=2" output.mp4
```

## Notes

- Use `-vf` for video filters
- Multiple filters separated by commas
- Use `-filter_complex` for complex operations
- Overlay positions: W=width, H=height, w=overlay width, h=overlay height
- Speed changes require both video (setpts) and audio (atempo) filters

Overview

This skill applies FFmpeg video filters to perform scaling, cropping, watermarks/overlays, speed changes, blur, brightness/contrast, rotation, fades, and chained visual effects. It provides practical filter examples and command patterns you can use directly with ffmpeg. Use it to prepare, enhance, or adapt video assets for delivery, social platforms, or postproduction tasks.

How this skill works

The skill exposes common ffmpeg -vf and -filter_complex patterns to transform video frames and combine streams. It shows how to scale with aspect-ratio preservation, crop specific regions, overlay images with position expressions, change playback speed (video and audio), apply blur and eq filters, rotate, and chain multiple filters. Examples highlight syntax, parameter choices, and typical placements for these filters in commands.

When to use it

  • Resize videos for target resolutions or platform limits
  • Crop or reframe footage to remove unwanted areas
  • Add branded watermarks or centered overlays
  • Change playback speed for time-lapse or slow-motion
  • Apply blur to obscure faces or sensitive regions
  • Adjust brightness, contrast, or saturation for color correction

Best practices

  • Keep aspect ratio by using -2 or -1 for one scale dimension
  • Use -filter_complex for combining inputs or complex overlay chains
  • Match audio tempo changes with atempo when changing video PTS
  • Prefer high-quality scaling flags (e.g., lanczos) for upscaling
  • Test overlay expressions like W-w-10 and (W-w)/2 on multiple resolutions
  • Chain filters with commas; name pads in filter_complex for clarity

Example use cases

  • Produce a 720p version of a source file while preserving aspect ratio
  • Crop a center 16:9 frame from a larger cinematic video
  • Add a semi-transparent logo to the bottom-right corner of all clips
  • Create a 2x speed time-lapse with matching audio tempo adjustment
  • Blur a moving region by applying boxblur to a coordinate-based area
  • Apply fade-in and fade-out to smooth scene transitions

FAQ

How do I preserve audio when changing video speed?

Apply setpts to the video and atempo to the audio. Use atempo values between 0.5 and 2.0; chain multiple atempo filters for larger changes.

When should I use -filter_complex instead of -vf?

-filter_complex is required when you combine multiple input streams (e.g., overlaying an image) or need labeled pads and more advanced graph operations. Use -vf for single-stream simple chains.