Skip to main content

Introduction

FFmpeg provides over 300 video filters for processing, analyzing, and transforming video streams. This reference documents filters found in the libavfilter/vf_*.c source files.

Filter Usage

Apply video filters using the -vf or -filter:v option:
ffmpeg -i input.mp4 -vf "scale=1280:720,fps=30" output.mp4

Scaling and Resizing

scale

Scale the input video size and/or convert the image format. Parameters:
  • w, width - Output width (can use expressions)
  • h, height - Output height (can use expressions)
  • flags - Scaling algorithm: fast_bilinear, bilinear, bicubic, lanczos
  • interl - Interlacing aware scaling
  • in_color_matrix - Input color matrix
  • out_color_matrix - Output color matrix
Examples:
# Scale to 1280x720
ffmpeg -i input.mp4 -vf scale=1280:720 output.mp4

# Scale to half size
ffmpeg -i input.mp4 -vf scale=iw/2:ih/2 output.mp4

# Scale maintaining aspect ratio
ffmpeg -i input.mp4 -vf scale=1280:-1 output.mp4

# High quality scaling with lanczos
ffmpeg -i input.mp4 -vf scale=1920:1080:flags=lanczos output.mp4

scale_cuda / scale_vulkan / scale_opencl

Hardware-accelerated scaling. Examples:
ffmpeg -hwaccel cuda -i input.mp4 -vf scale_cuda=1280:720 output.mp4

Cropping and Padding

crop

Crop the input video. Parameters:
  • w, out_w - Width of output (default: iw)
  • h, out_h - Height of output (default: ih)
  • x - Horizontal position of top-left corner
  • y - Vertical position of top-left corner
  • keep_aspect - Keep aspect ratio
  • exact - Exact cropping for subsampled formats
Examples:
# Crop to 640x480 from center
ffmpeg -i input.mp4 -vf crop=640:480 output.mp4

# Crop 100 pixels from each side
ffmpeg -i input.mp4 -vf crop=in_w-200:in_h-200:100:100 output.mp4

# Auto-detect crop area
ffmpeg -i input.mp4 -vf cropdetect -f null -

pad

Add padding to video. Examples:
# Add black bars to make 16:9
ffmpeg -i input.mp4 -vf pad=1920:1080:(ow-iw)/2:(oh-ih)/2 output.mp4

cropdetect

Auto-detect crop parameters. Examples:
ffmpeg -i input.mp4 -vf cropdetect -f null -

Frame Rate and Timing

fps

Force constant framerate. Parameters:
  • fps - Target frame rate
  • round - Rounding method: zero, inf, down, up, near
  • start_time - Start time offset
Examples:
# Convert to 30fps
ffmpeg -i input.mp4 -vf fps=30 output.mp4

# Convert to 60fps
ffmpeg -i input.mp4 -vf fps=60 output.mp4

framerate

Upconvert framerate with motion interpolation. Examples:
ffmpeg -i input.mp4 -vf framerate=fps=60 output.mp4

setpts

Change presentation timestamp. Examples:
# Double speed
ffmpeg -i input.mp4 -vf setpts=0.5*PTS output.mp4

# Half speed
ffmpeg -i input.mp4 -vf setpts=2*PTS output.mp4

Deinterlacing

yadif

Yet Another Deinterlacing Filter. Examples:
ffmpeg -i interlaced.mp4 -vf yadif output.mp4

bwdif

Bob Weaver Deinterlacing Filter. Examples:
ffmpeg -i interlaced.mp4 -vf bwdif output.mp4

w3fdif

Weston 3-field deinterlacing filter. Examples:
ffmpeg -i interlaced.mp4 -vf w3fdif output.mp4

bwdif_cuda / bwdif_vulkan

Hardware-accelerated deinterlacing. Examples:
ffmpeg -hwaccel cuda -i input.mp4 -vf bwdif_cuda output.mp4

Color Correction

colorbalance

Adjust color balance. Examples:
ffmpeg -i input.mp4 -vf colorbalance=rs=0.2:gs=-0.1:bs=0 output.mp4

colorchannelmixer

Adjust color channels. Examples:
ffmpeg -i input.mp4 -vf colorchannelmixer=rr=1:gg=1:bb=1 output.mp4

colorcontrast

Adjust color contrast. Examples:
ffmpeg -i input.mp4 -vf colorcontrast output.mp4

colorcorrect

Adjust color correction. Examples:
ffmpeg -i input.mp4 -vf colorcorrect output.mp4

colorize

Colorize video. Examples:
ffmpeg -i input.mp4 -vf colorize=hue=120:saturation=0.5:lightness=0 output.mp4

colorkey / colorkey_opencl

Chroma key (green screen) removal. Examples:
ffmpeg -i greenscreen.mp4 -vf colorkey=0x00FF00:0.3:0.2 output.mp4

colorlevels

Adjust color levels. Examples:
ffmpeg -i input.mp4 -vf colorlevels=rimin=0.1:gimin=0.1:bimin=0.1 output.mp4

colorspace / colorspace_cuda

Convert between color spaces. Examples:
ffmpeg -i input.mp4 -vf colorspace=bt709:bt2020 output.mp4

colortemperature

Adjust color temperature. Examples:
ffmpeg -i input.mp4 -vf colortemperature=temperature=6500 output.mp4

curves

Adjust color curves. Examples:
ffmpeg -i input.mp4 -vf curves=vintage output.mp4

eq

Adjust brightness, contrast, saturation. Examples:
ffmpeg -i input.mp4 -vf eq=brightness=0.1:contrast=1.5:saturation=1.2 output.mp4

hue

Adjust hue and saturation. Examples:
ffmpeg -i input.mp4 -vf hue=h=90:s=1.5 output.mp4

Overlays and Composition

overlay

Overlay a video source on top of the input. Parameters:
  • x, y - Position of overlay
  • eof_action - Action at end: repeat, endall, pass
  • eval - When to evaluate position: init, frame
  • format - Pixel format: yuv420, yuv422, yuv444, rgb, etc.
Examples:
# Overlay logo in top-right corner
ffmpeg -i video.mp4 -i logo.png -filter_complex "overlay=W-w-10:10" output.mp4

# Overlay with transparency
ffmpeg -i video.mp4 -i watermark.png -filter_complex "overlay=10:10:format=rgb" output.mp4

# Moving overlay
ffmpeg -i video.mp4 -i logo.png -filter_complex "overlay=x='t*100':y=10" output.mp4

blend

Blend two video streams. Examples:
ffmpeg -i video1.mp4 -i video2.mp4 -filter_complex "blend=all_mode=overlay:all_opacity=0.5" output.mp4

alphamerge

Merge alpha channel from another stream. Examples:
ffmpeg -i rgb.mp4 -i alpha.mp4 -filter_complex alphamerge output.mp4

Text and Graphics

drawtext

Draw text on video. Examples:
# Simple text overlay
ffmpeg -i input.mp4 -vf "drawtext=text='Hello World':fontsize=24:x=10:y=10" output.mp4

# Timestamp
ffmpeg -i input.mp4 -vf "drawtext=text='%{pts\\:hms}':fontsize=24:x=10:y=10" output.mp4

# Text from file
ffmpeg -i input.mp4 -vf "drawtext=textfile=subtitle.txt:fontsize=24:x=10:y=H-th-10" output.mp4

drawbox

Draw colored box. Examples:
ffmpeg -i input.mp4 -vf "drawbox=x=10:y=10:w=100:h=100:[email protected]:t=2" output.mp4

drawgrid

Draw grid. Examples:
ffmpeg -i input.mp4 -vf "drawgrid=width=100:height=100:thickness=2:[email protected]" output.mp4

Filters and Effects

blur / boxblur / avgblur

Blur video. Examples:
ffmpeg -i input.mp4 -vf boxblur=2:1 output.mp4
ffmpeg -i input.mp4 -vf avgblur=5 output.mp4

unsharp

Sharpen or blur video. Examples:
# Sharpen
ffmpeg -i input.mp4 -vf unsharp=5:5:1.0:5:5:0.0 output.mp4

nlmeans

Non-local means denoising. Examples:
ffmpeg -i noisy.mp4 -vf nlmeans output.mp4

hqdn3d

High quality 3D denoiser. Examples:
ffmpeg -i noisy.mp4 -vf hqdn3d output.mp4

atadenoise

Adaptive temporal averaging denoiser. Examples:
ffmpeg -i noisy.mp4 -vf atadenoise output.mp4

denoise_vaapi

Hardware-accelerated denoising. Examples:
ffmpeg -hwaccel vaapi -i input.mp4 -vf denoise_vaapi output.mp4

Rotation and Transformation

rotate

Rotate the input image. Parameters:
  • angle - Rotation angle in radians
  • out_w, ow - Output width
  • out_h, oh - Output height
  • fillcolor - Fill color for empty areas
Examples:
# Rotate 90 degrees clockwise
ffmpeg -i input.mp4 -vf rotate=PI/2 output.mp4

# Rotate 45 degrees
ffmpeg -i input.mp4 -vf rotate=45*PI/180 output.mp4

transpose

Transpose video. Examples:
# 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

hflip / vflip

Flip video horizontally or vertically. Examples:
ffmpeg -i input.mp4 -vf hflip output.mp4
ffmpeg -i input.mp4 -vf vflip output.mp4

perspective

Correct perspective. Examples:
ffmpeg -i input.mp4 -vf perspective=x0=0:y0=0:x1=W:y1=0:x2=0:y2=H:x3=W:y3=H output.mp4

Analysis and Detection

blackdetect

Detect black frames. Examples:
ffmpeg -i input.mp4 -vf blackdetect=d=0.1:pix_th=0.00 -f null -

blackframe

Detect frames that are mostly black. Examples:
ffmpeg -i input.mp4 -vf blackframe -f null -

scenedetect / freezedetect

Detect scene changes or frozen frames. Examples:
ffmpeg -i input.mp4 -vf select='gt(scene,0.4)',showinfo -f null -
ffmpeg -i input.mp4 -vf freezedetect -f null -

psnr / ssim

Calculate quality metrics. Examples:
ffmpeg -i reference.mp4 -i distorted.mp4 -filter_complex psnr -f null -
ffmpeg -i reference.mp4 -i distorted.mp4 -filter_complex ssim -f null -

signalstats

Analyze video signal. Examples:
ffmpeg -i input.mp4 -vf signalstats -f null -

histogram

Generate histogram. Examples:
ffmpeg -i input.mp4 -vf histogram output.mp4

waveform / vectorscope

Generate waveform or vectorscope. Examples:
ffmpeg -i input.mp4 -vf waveform output.mp4
ffmpeg -i input.mp4 -vf vectorscope output.mp4

Layout and Stacking

hstack / vstack

Stack videos horizontally or vertically. Examples:
# Side by side
ffmpeg -i left.mp4 -i right.mp4 -filter_complex hstack output.mp4

# Top and bottom
ffmpeg -i top.mp4 -i bottom.mp4 -filter_complex vstack output.mp4

xstack

Stack videos in custom grid. Examples:
ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -i 4.mp4 -filter_complex "xstack=inputs=4:layout=0_0|w0_0|0_h0|w0_h0" output.mp4

Fade Effects

fade

Fade in/out video. Examples:
# Fade in first 2 seconds
ffmpeg -i input.mp4 -vf fade=in:0:60 output.mp4

# Fade out last 2 seconds
ffmpeg -i input.mp4 -vf fade=out:900:60 output.mp4

# Both
ffmpeg -i input.mp4 -vf "fade=in:0:60,fade=out:900:60" output.mp4

Complete Video Filter List

FFmpeg includes over 300 video filters. Key filters from libavfilter/vf_*.c:
FilterDescription
addroiAdd region of interest
alphamergeMerge alpha channel
amplifyAmplify differences
aspectSet aspect ratio
atadenoiseTemporal denoiser
avgblurAverage blur
backgroundkeyBackground key removal
bboxDetect bounding box
bilateralBilateral filter
bitplanenoiseMeasure bit plane noise
blackdetectDetect black frames
blackframeDetect black frames
blendBlend two videos
bm3dBlock-matching 3D denoiser
boxblurBox blur
bwdifDeinterlacer
casContrast adaptive sharpening
chromakeyChroma key
ciescopeCIE color diagram
codecviewVisualize codec info
colorbalanceAdjust colors
colorkeyChroma key
colorlevelsAdjust color levels
colorspaceColor space conversion
convolutionApply convolution
cropCrop video
curvesAdjust color curves
datascopeVideo data analyzer
dblurDirectional blur
debandRemove banding
deflate / inflateDeflate/inflate
dejudderRemove judder
delogoRemove logo
denoiseDenoise video
deshakeStabilize video
despillRemove spill
detelecineInverse telecine
dilation / erosionMorphological ops
displaceDisplace pixels
drawboxDraw box
drawgridDraw grid
drawtextDraw text
edgedetectDetect edges
eqAdjust brightness/contrast
extractplanesExtract color planes
fadeFade in/out
fftfiltFFT filter
fieldExtract fields
fieldorderSet field order
fillbordersFill borders
find_rectFind rectangle
floodfillFlood fill
formatConvert pixel format
fpsChange framerate
framepackPack stereoscopic
framerateInterpolate framerate
freezedetectDetect frozen frames
gblurGaussian blur
gradfunGradient deband
hflipFlip horizontally
histogramGenerate histogram
hqdn3d3D denoiser
hqxScale by 2, 3, or 4
hstackStack horizontally
hueAdjust hue/saturation
hwupload / hwdownloadHardware transfer
identityCalculate identity
idetDetect interlacing
ilDeinterleave/interleave
inflateInflate filter
interlaceCreate interlaced
kerndeintKernel deinterlacer
lagfunLag effect
lenscorrectionLens correction
libvmafVMAF quality metric
limiterLimit pixels
loopLoop video
lut / lut3dLookup table
maskedclampClamp with mask
medianMedian filter
mestimateMotion estimation
minterpolateMotion interpolation
mixMix frames
monochromeConvert to monochrome
morphoMorphological filter
mpdecimateDrop duplicate frames
negateNegate colors
nlmeansNon-local means
nnediNeural network deinterlacer
noiseAdd noise
normalizeNormalize colors
nullPass through
oscilloscope2D oscilloscope
overlayOverlay video
padAdd padding
paletteGenerate palette
perspectiveCorrect perspective
pixelizePixelize video
ppPostprocessing
premultiplyPremultiply alpha
prewittPrewitt edge detection
pseudocolorPseudo color
psnrCalculate PSNR
pullupInverse telecine
qpChange QP
randomRandom filter
readeia608Read EIA-608 captions
remapRemap pixels
removegrainRemove grain
removelogoRemove logo
rotateRotate video
scaleScale video
scale2refScale to reference
scrollScroll video
selectSelect frames
separatefieldsSeparate fields
setdar / setsarSet aspect ratio
setfieldSet field type
setparamsSet parameters
shearShear video
showinfoShow frame info
showpaletteShow palette
shuffleframesShuffle frames
shuffleplanesShuffle planes
signalstatsSignal statistics
smartblurSmart blur
sobelSobel edge detection
splitSplit stream
sppSimple postprocessing
srSuper resolution
ssimCalculate SSIM
stereo3dStereoscopic conversion
streamselectSelect streams
super2xsaiScale by 2x
swaprectSwap rectangles
swapuvSwap U and V
tblendTemporal blend
telecineApply telecine
thresholdThreshold
thumbnailSelect thumbnail
tileTile video
tinterlaceTemporal interlace
tlut22-pass LUT
tmedianTemporal median
tmixMix frames
tonemapHDR to SDR
transposeTranspose
trimTrim video
unsharpSharpen/blur
untileUntile
v360360 video conversion
vaguedenoiserWavelet denoiser
vectorscopeVectorscope
vflipFlip vertically
vibranceBoost saturation
vignetteApply vignette
vmafmotionVMAF motion
vstackStack vertically
w3fdifWeston deinterlacer
waveformWaveform monitor
weaveWeave fields
xbrxBR scaler
xfadeCross fade
xmedianCross median
xstackStack in grid
yadifDeinterlacer
yaepblurYet another edge preserving blur
zoompanZoom and pan
zscaleScale with zimg

See Also

Build docs developers (and LLMs) love