How to record a specific window using ffmpeg?

前端 未结 6 803
说谎
说谎 2021-02-18 18:41

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         


        
6条回答
  •  [愿得一人]
    2021-02-18 19:14

    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.

提交回复
热议问题