FFmpeg Record Desktop Screen or Capture Video and Save as MP4 File in Windows 10

Are you looking for FFmpeg record screen or FFmpeg screen capture commands?

In this tutorial, you will learn how to Record Desktop Screen or Capture Video and Save it as MP4 File in Windows 10 using FFmpeg.

So, let’s get started.

Use FFmpeg DirectShow

FFmpeg can take input from DirectShow devices on your Windows computer. Have a look at the ​FFmpeg dshow input device documentation for official documentation. It can accept input from audio, video devices, video capture devices, and analog tv tuner devices.

For the sake of this tutorial, you can use this DirectShow device.

ffmpeg -f dshow -i video="screen-capture-recorder" output.mkv

This will grab the image from the entire desktop. You can also find other alternative devices by doing a Google search on the topic.

If you need audio too:

ffmpeg -f dshow -i video="UScreenCapture":audio="Microphone" output.mkv

If you want to capture the audio that is playing from your speakers you may also need to configure the so-called “Stereo Mix” device.


ffmpeg -f dshow -i video="UScreenCapture" -f dshow -i audio="Microphone" output.mkv

You can list your devices with:

ffmpeg -list_devices true -f dshow -i dummy

Use built-in GDI screengrabber

You can also use gdigrab as an input device to grab video from the Windows screen.

To capture all your displays as one big contiguous display:

ffmpeg -f gdigrab -framerate 30 -i desktop output.mkv

If you want to limit to a region and show the area being grabbed:

ffmpeg -f gdigrab -framerate 30 -offset_x 10 -offset_y 20 -video_size 640x480 -show_region 1 -i desktop output.mkv

To grab the contents of the window named “Calculator”:

ffmpeg -f gdigrab -framerate 30 -i title=Calculator output.mkv

Hardware Encoding

You can use hardware acceleration to speed up encoding and reduce the load on your CPU. For example, with NVIDIA hardware encoding:

ffmpeg -f gdigrab -framerate 30 -i desktop -c:v h264_nvenc -qp 0 output.mkv

Lossless Recording

If your CPU is not fast enough, the encoding process might take too long. To speed up the encoding process, you can use lossless encoding and disable advanced encoder options, e.g.:

ffmpeg -video_size 1920x1080 -framerate 30 -f x11grab -i :0.0 -c:v libx264rgb -crf 0 -preset ultrafast output.mkv

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.