For example, to grab the entire desktop using ffmpeg:

ffmpeg -f gdigrab -framerate 6 -i desktop out.mpg
There are two options for the input filename:

desktop
For example:

ffmpeg -f gdigrab -show_region 1 -framerate 6 -video_size cif -offset_x 10 -offset_y 20 -i desktop out.mpg
Grab a 640x480 region at position 10,20:

ffmpeg -f gdigrab -framerate 6 -offset_x 10 -offset_y 20 -video_size vga -i desktop out.mpg
Grab the contents of the window named "Calculator"

ffmpeg -f gdigrab -framerate 6 -i title=Calculator out.mpg

Recommend

FFMPEG ffmpeg Documentation 26 Input Devices 26.8 gdigrab

FFMPEG ffmpeg Documentation 26 Input Devices 26.7 fbdev

FFMPEG ffmpeg Documentation 26 Input Devices 26.6 dshow 26.6.2 Examples

FFMPEG ffmpeg Documentation 26 Input Devices 26.6 dshow

FFMPEG ffmpeg Documentation 26 Input Devices 26.5 decklink 26.5.2 Examples

FFMPEG ffmpeg Documentation 26 Input Devices 26.3 avfoundation 26.3.2 Examples

FFMPEG ffmpeg Documentation 26 Input Devices 26.3 avfoundation

FFMPEG ffmpeg Documentation 26 Input Devices 26.1 alsa

FFMPEG ffmpeg Documentation 24 Protocols 24.43 zmq

FFMPEG ffmpeg Documentation 24 Protocols 24.42 unix

FFMPEG ffmpeg Documentation 24 Protocols 24.41 udp 24.41.1 Examples

FFMPEG ffmpeg Documentation 24 Protocols 24.41 udp

FFMPEG ffmpeg Documentation 24 Protocols 24.40 tls

FFMPEG ffmpeg Documentation 24 Protocols 24.39 tcp

FFMPEG ffmpeg Documentation 24 Protocols 24.38 tee

FFMPEG ffmpeg Documentation 24 Protocols 24.37 subfile

FFMPEG ffmpeg Documentation 24 Protocols 24.35 srt

FFMPEG ffmpeg Documentation 24 Protocols 24.34 sctp

FFMPEG ffmpeg Documentation 24 Protocols 24.33 sap 24.33.2 Demuxer

FFMPEG ffmpeg Documentation 24 Protocols 24.33 sap 24.33.1 Muxer

FFMPEG ffmpeg Documentation 24 Protocols 24.32 rtsp 24.32.1 Examples

FFMPEG ffmpeg Documentation 24 Protocols 24.32 rtsp

FFMPEG ffmpeg Documentation 24 Protocols 24.30 librtmp rtmp, rtmpe, rtmps, rtmpt, rtmpte

FFMPEG ffmpeg Documentation 24 Protocols 24.29 libssh

FFMPEG ffmpeg Documentation 24 Protocols 24.22 rtmp

FFMPEG ffmpeg Documentation 24 Protocols 24.19 pipe

FFMPEG ffmpeg Documentation 24 Protocols 24.18 md5

FFMPEG ffmpeg Documentation 24 Protocols 24.17 mmsh

FFMPEG ffmpeg Documentation 24 Protocols 24.15 Icecast

FFMPEG ffmpeg Documentation 24 Protocols 24.14 http 24.14.1 HTTP Cookies

FFMPEG ffmpeg Documentation 24 Protocols 24.14 http

FFMPEG ffmpeg Documentation 24 Protocols 24.13 hls

FFMPEG ffmpeg Documentation 24 Protocols 24.10 ftp

FFMPEG ffmpeg Documentation 24 Protocols 24.9 file

FFMPEG ffmpeg Documentation 24 Protocols 24.8 data

FFMPEG ffmpeg Documentation 24 Protocols 24.7 crypto

FFMPEG ffmpeg Documentation 24 Protocols 24.6 concatf

FFMPEG ffmpeg Documentation 24 Protocols 24.5 concat

FFMPEG ffmpeg Documentation 24 Protocols 24.4 cache

FFMPEG ffmpeg Documentation 24 Protocols 24.3 bluray

FFMPEG ffmpeg Documentation 24 Protocols 24.2 async

FFMPEG ffmpeg Documentation 24 Protocols 24.1 amqp

FFMPEG ffmpeg Documentation 22 Metadata

FFMPEG ffmpeg Documentation 21 Muxers 21.35 webm_dash_manifest 21.35.2 Example

FFMPEG ffmpeg Documentation 21 Muxers 21.34 webm_chunk 21.34.2 Example

FFMPEG ffmpeg Documentation 21 Muxers 21.33 tee 21.33.2 Examples

FFMPEG ffmpeg Documentation 21 Muxers 21.30 segment, stream_segment, ssegment 21.30.2 Examples

FFMPEG ffmpeg Documentation 21 Muxers 21.30 segment, stream_segment, ssegment 21.30.1 Options

FFMPEG ffmpeg Documentation 21 Muxers 21.27 nut

FFMPEG ffmpeg Documentation 21 Muxers 21.26 null

FFMPEG ffmpeg Documentation 21 Muxers 21.24 mpegts 21.24.1 Options

FFMPEG ffmpeg Documentation 21 Muxers 21.23 mp3

FFMPEG ffmpeg Documentation 21 Muxers 21.22 mov, mp4, ismv 21.22.2 Example

FFMPEG ffmpeg Documentation 21 Muxers 21.21 md5 21.21.1 Examples

FFMPEG ffmpeg Documentation 21 Muxers 21.20 matroska 21.20.1 Metadata

FFMPEG ffmpeg Documentation 21 Muxers 21.19 image2 21.19.2 Examples

FFMPEG ffmpeg Documentation 21 Muxers 21.18 ico

FFMPEG ffmpeg Documentation 21 Muxers 21.17 hls 21.17.1 Options