Generate Moving Dot Test Pattern with FFmpeg
Generating a moving dot test pattern in FFmpeg is a reliable method
to test display refresh rates, detect frame drops, and measure motion
judder across video playback pipelines. While the standard
testsrc filter creates a static color bar grid with a
scrolling gradient and timecode, pairing it with the
drawbox filter allows you to render a moving dot or shape
with mathematically controlled motion. This guide demonstrates how to
generate a moving dot over a testsrc background, configure
its movement paths, and utilize FFmpeg's built-in motion test
alternatives.
Overlaying a Moving Dot on
testsrc
To create a moving dot directly on the standard testsrc
pattern, use the drawbox video filter to draw a solid
square or dot whose x and y coordinates update
dynamically based on the current timestamp variable t.
Run the following command to generate a circular or orbital moving dot:
ffmpeg -f lavfi -i testsrc=size=1920x1080:rate=60:duration=10 -vf "drawbox=x='(w-40)/2 + cos(t*3)*(w/4)':y='(h-40)/2 + sin(t*3)*(h/4)':w=40:h=40:color=white:t=fill" -c:v libx264 -pix_fmt yuv420p moving_dot_orbital.mp4In this command:
testsrc=size=1920x1080:rate=60:duration=10creates a 1080p canvas running at 60 frames per second for 10 seconds.drawboxdraws a 40x40 pixel white square (w=40:h=40:color=white:t=fill).cos(t*3)andsin(t*3)use trigonometry relative to timestamptto orbit the dot smoothly around the center of the frame.-pix_fmt yuv420pensures broad compatibility with media players.
Creating a Linear Sweeping Dot
If you need a dot that sweeps horizontally across the screen to test
linear frame pacing and tearing, use the modulo operator
mod():
ffmpeg -f lavfi -i testsrc=size=1280x720:rate=60:duration=10 -vf "drawbox=x='mod(t*400, w)':y='(h-30)/2':w=30:h=30:color=red:t=fill" -c:v libx264 -pix_fmt yuv420p moving_dot_linear.mp4x='mod(t*400, w)'moves the dot across the screen at 400 pixels per second, wrapping back to the left edge when it reaches the canvas widthw.y='(h-30)/2'keeps the dot vertically centered.
Using the Built-In
testsrc2 Motion Pattern
If you do not require custom motion paths and simply need an
out-of-the-box motion test pattern, FFmpeg includes an updated variant
called testsrc2. This filter natively includes a moving
element that travels across the frame without requiring additional
filters:
ffmpeg -f lavfi -i testsrc2=size=1920x1080:rate=60:duration=10 -c:v libx264 -pix_fmt yuv420p testsrc2_motion.mp4The testsrc2 pattern generates color bars alongside an
animated block designed specifically to verify smooth motion rendering
and detect frame tearing.