How to record screen with FFmpeg?

I want to record my screen and make a video out of it, is there any way I can do it using FFmpeg?

FFmpeg allows screen recording with all kinds of platforms and it is very easy to it. There is a complete guide created by FFmpeg for screen recording. You can find all the details below.
https://trac.ffmpeg.org/wiki/Capture/Desktop

To capture screen films in Windows 10, I’m using Ffmpeg:

Ffmpeg with the following settings: -rtbufsize 1500M -f gdigrab -framerate 29.97 -draw mouse 0 -offset x 2777 -offset y 344 -video size 1280x720 -i desktop -c:v libx264 -vf format=yuv420p -preset ultrafast D:/myvideo.mpg

The recorded files playback without any issues in VLC. This issue message appears when I play them back in the default Windows Media Player or “Movies & TV” ERROR INVALID MODULETYPE 0xc10100be

Do I have to add any settings to Ffmpeg in order to use it on Windows?

Try this:

Replace .mpg with .mp4.

Thanks, Uma!

I recently made the changes as you suggest but nothing happened, still getting the same error.

Any other idea?

Did you truly rerun the command with the correct output name (myvideo.mp4), or you just alter the name of the existing file?

Thank you!

I had forgotten that “mpg” files are not the same as “mp4” as a container. Nicely rounded up.

Setting the output file format to “.mp4” was therefore part one. Although the Windows players were still showing black video, this at least halted the crashes and problems. Setting the pixel size to yuv420p was part two.

Here is a working FFmpeg command, though I’m sure it may be improved:

ffmpeg -rtbufsize 1500M -f gdigrab -framerate 29.97 -draw_mouse 0 -offset_x 2633 -offset_y 103 -video_size 1280x720 -i desktop -pix_fmt yuv420p -c:v libx264 -preset ultrafast D:/myvideo.mp4