About headless(ssh remote login) run environment
wnpllrzodiac opened this issue · comments
There is another solution:
1 EXPORT DISPLAY=.0:0
2 init ogl render to off-screen buffer (MAYBE optional)
3 call ffmpeg transcode command as usually.
test passed on ubuntu18.04 x64
int no_window_init()
{
glXCreateContextAttribsARBProc glXCreateContextAttribs = NULL;
glXCreateContextAttribs =
(glXCreateContextAttribsARBProc)glXGetProcAddressARB(
(const GLubyte *)"glXCreateContextAttribsARB");
const char *displayName = NULL;
Display *display;
display = XOpenDisplay(displayName);
static int visualAttribs[] = {
GLX_SAMPLE_BUFFERS, 1, GLX_SAMPLES, 4
};
int numberOfFramebufferConfigurations = 0;
GLXFBConfig *fbConfigs;
fbConfigs = glXChooseFBConfig(
display, DefaultScreen(display), visualAttribs, &numberOfFramebufferConfigurations);
int context_attribs[] = {
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
GLX_CONTEXT_MINOR_VERSION_ARB, 0,
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB,
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
None};
GLXContext glContext[NUM];
glContext[0] = glXCreateContextAttribs(display, fbConfigs[0], 0, 1, context_attribs);
GLXPbuffer pbuffer;
int pbufferAttribs[] = {
GLX_PBUFFER_WIDTH, 32,
GLX_PBUFFER_HEIGHT, 32,
None
};
pbuffer = glXCreatePbuffer(display, fbConfigs[0], pbufferAttribs);
XFree(fbConfigs);
XSync(display, False);
glXMakeContextCurrent(display, pbuffer, pbuffer, glContext[0]);
return 0;
}
static av_cold int init(AVFilterContext *ctx)
{
GlMirrorContext *gs = ctx->priv;
if (gs->no_window) {
av_log(NULL, AV_LOG_ERROR, "open gl no window init ON\n");
no_window_init();
}
return glfwInit() ? 0 : -1;
}
Thanks , I recved and will try this week~
You can also submit a pull request for this issue~ ^_^
[Background]
I compiled the ffmpeg on centos,and it worked well with xvfb.
But I find it does not use gpu,and I don't kown the reason.
There is a nvidia video card on my server.
So I want to try the no_window_init solution.
[Question]
When I use the no_window_init,It crashed at glXChooseFBConfig
, and the display variable is null after XOpenDisplay
.
Is there some additional operation when use no_window_init
?
I am looking forward to your advice,thanks very much!