How to configure frame rate and cursor in ffmpeg x11grab
Recording your Linux desktop with FFmpeg’s x11grab
device allows for highly customizable screen captures. This guide
provides a straightforward explanation of how to configure both the
capture frame rate and the visibility of the mouse cursor during your
recording sessions, ensuring you get the exact video output you
need.
Configuring the Capture Frame Rate
To set the frame rate (frames per second) for your screen capture,
use the -framerate input option. Placing this option before
the input device tells FFmpeg how many frames per second to capture from
your X11 display.
The syntax for setting the frame rate is:
ffmpeg -f x11grab -framerate <fps_value> -i :0.0 output.mp4For example, to capture your screen at a smooth 60 FPS:
ffmpeg -f x11grab -framerate 60 -i :0.0 output.mp4To capture at a standard 30 FPS:
ffmpeg -f x11grab -framerate 30 -i :0.0 output.mp4Configuring the Mouse Cursor Display
You can control whether the mouse cursor is visible in the recorded
video using the -draw_mouse option. This is an input option
that accepts binary values:
1enables the mouse cursor (default behavior).0hides the mouse cursor entirely.
Hide the Mouse Cursor
To record the screen without capturing any mouse movements, set
-draw_mouse to 0:
ffmpeg -f x11grab -draw_mouse 0 -i :0.0 output.mp4Show the Mouse Cursor
To ensure the mouse cursor is recorded (which is useful for
tutorials), set -draw_mouse to 1 (or omit the
option, as it is enabled by default):
ffmpeg -f x11grab -draw_mouse 1 -i :0.0 output.mp4Combining Frame Rate and Cursor Options
In most scenarios, you will want to configure both options simultaneously. Here is how to combine them into a single, cohesive command.
To capture your screen at 60 FPS with the mouse cursor hidden:
ffmpeg -f x11grab -framerate 60 -draw_mouse 0 -i :0.0 output.mp4To capture your screen at 30 FPS with the mouse cursor visible:
ffmpeg -f x11grab -framerate 30 -draw_mouse 1 -i :0.0 output.mp4