<p>Two ways:</p>

<p><strong>#1</strong> By specifying gdigrab options:</p>

<pre><code>ffmpeg -f gdigrab -framerate 24 -video_size 960x540 -offset_x 240 -offset_y 450 -i desktop -preset ultrafast -pix_fmt yuv420p out.mp4
</code></pre>

<p>This captures a 960x540 video whose top-left corner is at (240,450) measured from the top-left corner of the display.</p>

<p><strong>#2</strong> By cropping it post-capture</p>

<pre><code>ffmpeg -f gdigrab -framerate 24 -i desktop -vf crop=960:540:240:450 -preset ultrafast -pix_fmt yuv420p out.mp4
</code></pre>

<p>The former is preferable.</p>

CC BY-SA 3.0
2017-07-28T05:01:25.583Z
2017-07-28T05:01:25.583Z
Gyan
<p>I'm using this line to record from the desktop to a video file:</p>

<pre><code>ffmpeg -f gdigrab -framerate 24 -i desktop -preset ultrafast -pix_fmt yuv420p out.mp4
</code></pre>

<p>But this will record the whole desktop.
Is there any way to record in real time only specific area/part of the desktop ?</p>

<ffmpeg>
How can i crop part of a video while recording from desktop in real time using ffmpeg?
Hanan
# How can i crop part of a video while recording from desktop in real time using ffmpeg?

(Asked by: username_0 on 2017-07-27)

I'm using this line to record from the desktop to a video file:
ffmpeg -f gdigrab -framerate 24 -i desktop -preset ultrafast -pix_fmt yuv420p out.mp4

But this will record the whole desktop.
Is there any way to record in real time only specific area/part of the desktop ?

**Tags:** ffmpeg


---

## 1 answers

### Answer by username_1 on 2017-07-28. Score: 2

Two ways:
#1 By specifying gdigrab options:
ffmpeg -f gdigrab -framerate 24 -video_size 960x540 -offset_x 240 -offset_y 450 -i desktop -preset ultrafast -pix_fmt yuv420p out.mp4

This captures a 960x540 video whose top-left corner is at (240,450) measured from the top-left corner of the display.
#2 By cropping it post-capture
ffmpeg -f gdigrab -framerate 24 -i desktop -vf crop=960:540:240:450 -preset ultrafast -pix_fmt yuv420p out.mp4

The former is preferable.


---

