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
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 the contents of the window named "Calculator"

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

Recommend

FFMPEG ffprobe Documentation 20 Input Devices 20.8 gdigrab

FFMPEG ffprobe Documentation 20 Input Devices 20.7 fbdev

FFMPEG ffprobe Documentation 20 Input Devices 20.6 dshow 20.6.2 Examples

FFMPEG ffprobe Documentation 20 Input Devices 20.6 dshow

FFMPEG ffprobe Documentation 20 Input Devices 20.5 decklink 20.5.2 Examples

FFMPEG ffprobe Documentation 20 Input Devices 20.3 avfoundation 20.3.2 Examples

FFMPEG ffprobe Documentation 20 Input Devices 20.3 avfoundation

FFMPEG ffprobe Documentation 20 Input Devices 20.1 alsa

FFMPEG ffprobe Documentation 18 Protocols 18.43 zmq

FFMPEG ffprobe Documentation 18 Protocols 18.42 unix

FFMPEG ffprobe Documentation 18 Protocols 18.41 udp 18.41.1 Examples

FFMPEG ffprobe Documentation 18 Protocols 18.41 udp

FFMPEG ffprobe Documentation 18 Protocols 18.40 tls

FFMPEG ffprobe Documentation 18 Protocols 18.39 tcp

FFMPEG ffprobe Documentation 18 Protocols 18.38 tee

FFMPEG ffprobe Documentation 18 Protocols 18.37 subfile

FFMPEG ffprobe Documentation 18 Protocols 18.35 srt

FFMPEG ffprobe Documentation 18 Protocols 18.34 sctp

FFMPEG ffprobe Documentation 18 Protocols 18.33 sap 18.33.2 Demuxer

FFMPEG ffprobe Documentation 18 Protocols 18.33 sap 18.33.1 Muxer

FFMPEG ffprobe Documentation 18 Protocols 18.32 rtsp 18.32.1 Examples

FFMPEG ffprobe Documentation 18 Protocols 18.32 rtsp

FFMPEG ffprobe Documentation 18 Protocols 18.30 librtmp rtmp, rtmpe, rtmps, rtmpt, rtmpte

FFMPEG ffprobe Documentation 18 Protocols 18.29 libssh

FFMPEG ffprobe Documentation 18 Protocols 18.22 rtmp

FFMPEG ffprobe Documentation 18 Protocols 18.20 prompeg

FFMPEG ffprobe Documentation 18 Protocols 18.19 pipe

FFMPEG ffprobe Documentation 18 Protocols 18.18 md5

FFMPEG ffprobe Documentation 18 Protocols 18.17 mmsh

FFMPEG ffprobe Documentation 18 Protocols 18.15 Icecast

FFMPEG ffprobe Documentation 18 Protocols 18.14 http 18.14.1 HTTP Cookies

FFMPEG ffprobe Documentation 18 Protocols 18.14 http

FFMPEG ffprobe Documentation 18 Protocols 18.13 hls

FFMPEG ffprobe Documentation 18 Protocols 18.10 ftp

FFMPEG ffprobe Documentation 18 Protocols 18.9 file

FFMPEG ffprobe Documentation 18 Protocols 18.8 data

FFMPEG ffprobe Documentation 18 Protocols 18.7 crypto

FFMPEG ffprobe Documentation 18 Protocols 18.6 concatf

FFMPEG ffprobe Documentation 18 Protocols 18.5 concat

FFMPEG ffprobe Documentation 18 Protocols 18.4 cache

FFMPEG ffprobe Documentation 18 Protocols 18.3 bluray

FFMPEG ffprobe Documentation 18 Protocols 18.2 async

FFMPEG ffprobe Documentation 18 Protocols 18.1 amqp

FFMPEG ffprobe Documentation 16 Metadata

FFMPEG ffprobe Documentation 15 Demuxers 15.20 tedcaptions

FFMPEG ffprobe Documentation 15 Demuxers 15.19 sbg

FFMPEG ffprobe Documentation 15 Demuxers 15.18 rawvideo

FFMPEG ffprobe Documentation 15 Demuxers 15.15 mov/mp4/3gp 15.15.2 Audible AAX

FFMPEG ffprobe Documentation 15 Demuxers 15.11 image2 15.11.1 Examples

FFMPEG ffprobe Documentation 15 Demuxers 15.11 image2

FFMPEG ffprobe Documentation 15 Demuxers 15.9 gif

FFMPEG ffprobe Documentation 15 Demuxers 15.8 flv, live_flv, kux

FFMPEG ffprobe Documentation 15 Demuxers 15.5 concat 15.5.3 Examples

FFMPEG ffprobe Documentation 13 Bitstream Filters 13.26 prores_metadata

FFMPEG ffprobe Documentation 13 Bitstream Filters 13.25 pcm_rechunk

FFMPEG ffprobe Documentation 13 Bitstream Filters 13.23 noise 13.23.1 Examples

FFMPEG ffprobe Documentation 13 Bitstream Filters 13.22 mpeg4_unpack_bframes

FFMPEG ffprobe Documentation 13 Bitstream Filters 13.17 mjpeg2jpeg

FFMPEG ffprobe Documentation 13 Bitstream Filters 13.16 imxdump

FFMPEG ffprobe Documentation 13 Bitstream Filters 13.15 hevc_mp4toannexb

FFMPEG ffprobe Documentation 13 Bitstream Filters 13.12 h264_mp4toannexb

FFMPEG ffprobe Documentation 13 Bitstream Filters 13.10 hapqa_extract

FFMPEG ffprobe Documentation 13 Bitstream Filters 13.9 filter_units

FFMPEG ffprobe Documentation 13 Bitstream Filters 13.5 dump_extra

FFMPEG ffprobe Documentation 13 Bitstream Filters

FFMPEG ffprobe Documentation 8 Codec Options

FFMPEG ffprobe Documentation 7 Expression Evaluation

FFMPEG ffprobe Documentation 6 Syntax 6.3 Time duration