How to record a specific window using ffmpeg?

This example works for me:

ffmpeg -f gdigrab -framerate 30 -i title="german.avi - VLC media player" -b:v 3M  germ.flv

where "title" means actual title of a target window.

Hope this will help.


I was also looking for a solution online, but was not satisfied with the answers I found. I have now fiddled together this very simplistic solution for linux:

ffmpeg -f x11grab -framerate 25 \
    $(xwininfo | gawk 'match($0, /-geometry ([0-9]+x[0-9]+).([0-9]+).([0-9]+)/, a)\
      { print "-video_size " a[1] " -i +" a[2] "," a[3] }') \
    $(date +%Y-%m-%d_%H-%M_%S).mp4
  • After executing this command the window can be selected with the mouse pointer

  • The target filename will take the form YYYY-mm-dd_hh_mm_ss.mp4 in the current directory.

  • The awk magic there just parses the window info. It is ugly and only works with gnu awk, but I have not found a better way yet to parse the window geometry into a custom format.

The syntax to record a specific rectangle on screen is:

-video_size [width]x[height] -i [x],[y]

and should also work under windows and with dshow, I believe.