I use ffmpeg to record a window using this code:
ffmpeg.exe
-f dshow
-y
-i video=\"screen-capture-recorder\":audio=\"virtual-audio-capturer\":audio=\"Microphon
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
This doesn't work on windows where xwininfo returns the "size" portion of the geometry in character cells instead of pixels (e.g. terminal windows). To fix this, the size needs to be extracted from the Width: and Height: fields of the xwininfo response.