vaCopySurfaceGLX return VA_STATUS_ERROR_UNKNOWN
Hlongyu opened this issue · 2 comments
Hlongyu commented
I am trying to copy ffmpeg vaapi frame to opengl. so i use vaCopySurfaceGLX() to do it, but it return VA_STATUS_ERROR_UNKNOWN
Linux amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.90-1 (2024-05-03) x86_64 GNU/Linux
libva info: VA-API version 1.22.0
libva info: Trying to open /lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_17
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.22 (libva 2.12.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 23.1.1 ()
vainfo: Supported profile and entrypoints
VAProfileMPEG2Simple : VAEntrypointVLD
VAProfileMPEG2Main : VAEntrypointVLD
VAProfileH264Main : VAEntrypointVLD
VAProfileH264Main : VAEntrypointEncSliceLP
VAProfileH264High : VAEntrypointVLD
VAProfileH264High : VAEntrypointEncSliceLP
VAProfileJPEGBaseline : VAEntrypointVLD
VAProfileJPEGBaseline : VAEntrypointEncPicture
VAProfileH264ConstrainedBaseline: VAEntrypointVLD
VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
VAProfileVP8Version0_3 : VAEntrypointVLD
VAProfileHEVCMain : VAEntrypointVLD
Here is my code.
GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, frame->width, frame->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glBindTexture(GL_TEXTURE_2D, 0);
void *gl_surface;
st = vaCreateSurfaceGLX(va_display, GL_TEXTURE_2D, texture, &gl_surface); //return 0
std::cout << "careate stauts is " << st << std::endl;
VASurfaceID id = (uintptr_t) frame->data[3]; //frame created by same va_display
st = vaCopySurfaceGLX(va_display, gl_surface, id, VA_FRAME_PICTURE); //return -1
std::cout << "Copy status is " << st << std::endl;
May be Texture format error? I can't find any example about how to use this api.
xhaihao commented
May be Texture format error? I can't find any example about how to use this api.
You may refer to https://github.com/gbeauchesne/mplayer-vaapi/blob/hwaccel-vaapi/libvo/vo_vaapi.c, but the recommended way is to map a vaapi surface to an egl image, then use this egl image. You should be able to find lots of examples.