Solution for multi GPU offload - mixing and encoding

Hi,

I would like to share my experience with regards to multi GPU offload:

  1. For encoding, it can be done adding “gpu” parameter for the video stream to the encoder of the ffmpeg_consumer.cpp
    av_opt_set(enc.get()->priv_data, "gpu", gpu_spec.c_str(), 0);
  2. For mixing, the solution is a combination of system configuration and code changes.
  • System configuration: As the opengl context via X11 is needed for mixing, in order to be able to choose the GPU on which the mixing should be done we need in linux so called “multi-seat” configuration, for simplicity we assume that we have two GPUs on which we want to do mixing, so it can be summarized as follows:
    • By default the system has (Seat0) with two GPUs in it
    • Create Seat1 with one GPU with its corresponding framebuffer
    • Configure display manager to start two X servers with two seats
  • Code change: x11_util.cpp: Change the code from
    Display* disp = XOpenDisplay(nullptr);
    to
    Display* disp = XOpenDisplay( "localhost:x.y");
    where x is the device and y is the screen, i.e. if we want to access the framebuffer of second X server we started we can use localhost:1.0 and all this to be configurable.

As a result of all above, a multi GPU offload for encoding and mixing is done, on dual-core system for CasparCG server, both from docker and standalone.

Thanks to @Julusian for the guidelines!

Hope this will help to somebody!

1 Like

Could you open a PR for this? hopefully you have the value being passed in from AMCP?

I am hoping this is not a necessary change? It should only affect the screen consumer when trying to set the windows as always on top. I don’t see why the window would be opened on the non default xserver and require this change