ShayBox / Mon2Cam

Workaround for multi-monitor Discord screensharing
MIT License
337 stars 33 forks source link

Hardware acceleration #20

Closed itsfolf closed 3 years ago

itsfolf commented 4 years ago

Currently Mon2Cam takes plenty of CPU resources which is problematic for screen sharing games, would it be possible to use hardware acceleration on ffmpeg (possibly VAAPI) to improve this?

botiapa commented 4 years ago

Good question, never used hw acceleration in ffmpeg before, but I'll try to look into it.

Some info I found: https://developer.nvidia.com/ffmpeg

ShayBox commented 4 years ago

This is possible, though it depends on your build of ffmpeg, most distros don't compile with hw accel support.

itsfolf commented 4 years ago

@ShayBox I have an AMD GPU and I usually use vaapi for hardware acceleration however I couldn't get it working with this since it requires the v4l2 format, could you help?

ShayBox commented 4 years ago

I don't really understand v4l2 or ffmpeg that well, on top of distros not compiling with hwaccel there's multiple types of it, VA-API, VDPAU, NVDECODE/NVENCODE, of which are gpu brand exclusive afaik, the best solution would be to compile ffmpeg to have vaapi/vdpau/nvenc and add the option to ffmpeg on your own local copy of mon2cam, but I wouldn't know how to solve any v4l2 formatting issues, or if v4l2loopback can even support custom formats for those codecs.

ShayBox commented 3 years ago

I'm going to close this, but if anyone is interested in a way to do this, you can modprobe v4l2loopback to create a device and use obs or ffmpeg compiled with your gpus hardware accel to stream to it