To record a video of 1280x1040 resolution starting from the coordinates 0 (horizontal) and 40 (vertical) from the top left corner of the screen run the following command:
ffmpeg \ -video_size 1280x1040 \ -framerate 60 \ -f x11grab \ -i ${DISPLAY}+0,40 \ -codec:v libx264 \ -crf 16 \ -preset slower \ ~/Videos/screen-recording.mp4
-videosize
sets the width and height of the area, which is captured by FFMPEG.
-framerate
sets the number of frames, which FFMPEG shall try to capture during every second.
-f x11grab
tells FFMPEG to grab frames from the X11 display server as input data.
-i ${DISPLAY}+0,40
tells FFMPEG which display to capture and tells it to capture an area, which starts at 0
(horizontal), 40
(vertical).
-codec:v libx264
tells FFMPEG to encode only a video stream (:v
) and use libx264
for encoding.
-crf
tells FFMPEG what the quality of the video should be. Lower means better quality. Default for x264 encoder is 23
. Default for x265 encoder is 28
.
-preset
tells FFMPEG how much time to spend on compressing frames. Possible values are: