there are a lot of tools which does this task.
But at the end of the day I used screen-capture-recorder.
Screen Capturer Recorder has an screen and audio grapper which can be used by ffmpeg, gstreamer and compatible tools. screen-capture-recorder has not a GUI interface but configured once it does its jobs.
Download the latest version from the release page and install it. In this example to the default directory C:\Program Files (x86)\Screen Capturer Recorder.
The package has ffmpeg “on board” so you can start immediately. A first simple example:
This command line records the main screen and all audio with a framerate of 10 fps
C:> "C:\Program Files (x86)\Screen Capturer Recorder\configuration_setup_utility\vendor\ffmpeg\bin\ffmpeg.exe" -f dshow -i audio="virtual-audio-capturer":video="screen-capture-recorder" -r 10 D:\temp\test_screen_capture.mp4 -r 10
But it is recommended to get hte latest version for Windows.
Screen Capturer Recorder is also configurable by some registry keys. The registry key is HKEY_CURRENT_USER\Software\screen-capture-recorder. Possible values:
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\screen-capture-recorder] "capture_height="=dword:000001E0 "capture_width=dword:00000280 "start_x=dword:00000000 "start_y=dword:00000000 "default_max_fps=dword:0000000A "stretch_to_width=dword:000001E0 "stretch_to_height=dword:00000280 "stretch_mode_high_quality_if_1=dword:00000000 "hwnd_to_track=dword:0000000A "disable_aero_for_vista_plus_if_1=dword:00000001 "track_new_x_y_coords_each_frame_if_1=dword:00000000 "capture_mouse_default_1=dword:00000001 "capture_foreground_window_if_1=dword:00000000 "dedup_if_1=dword:00000000 "millis_to_sleep_between_poll_for_dedupe_changes=dword:0000000A "capture_transparent_windows_including_mouse_in_non_aero_if_1_causes_annoying_mouse_flicker=dword:00000000 "hwnd_to_track_with_window_decoration=dword:0000000A
These are only example values. Adjust to your need or delete the one you not need.
Note: Screengrapping is also possible with the ffmpeg builtin input device gdigrab .
gdigrab can capture all screens.
C:> ffmpeg.exe -f gdigrab -framerate 10 -i desktop D:\temp\test_screen_capture.mp4
and with audio
C:> ffmpeg.exe -f gdigrab -framerate 10 -i desktop -f dshow -i audio="virtual-audio-capturer" D:\temp\test_screen_capture.mp4
gdigrap can either grap the whole desktop or a single window specified by the windows title. Take a look at the documentation for all options.