How to take a screenshot of desktop fast with Java in Windows (ffmpeg, etc.)?

后端 未结 4 703
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-28 09:56

I would like to use java to take a screenshot of my machine using FFMPEG or some other solution. I know linux works with ffmpeg without JNI, but running it in Windows does n

4条回答
  •  醉梦人生
    2020-12-28 10:11

    According to the official ffmpeg documentation you should be able to keep it pretty cross platform if you make the file parameter passed to the FFmpegFrameGrabber (which is really an input parameter that gets passed down as the -i option to ffmpeg) adhere to the different formats each device expects.

    ie:

    for Windows: dshow expects -i video="screen-capture-recorder"

    for OSX: avfoundation expects -i "":

    and for Linux: x11grab expects -i :+,.

    So just passing those values (arguments to -i) to the constructor and setting the format (via setFormat) accordingly should do the trick.

提交回复
热议问题