Hi,
I try to use cudaEglStreamProducer to push cuda data over EGL into gstreamer nveglstreamsrc for encoding. I started with example:
- tegra_multimedia_api/argus/samples/gstVideoEncode
However I needed a way to create a producer to push cuda data in so I found this example which helps me a lot:
- /cuda/samples/3_Imaging/EGLStreams_CUDA_Interop
I also found some helpful EGLStream Example provided by DaneLLL here:
I think I got most of the infrastructure running but I didnt got the frames into the producer.
This is how I initialized everything:
CUresult cuResult;
CUdevice cudaDevice;
cuResult = cuInit(0);
cuResult = cuDeviceGet(&cudaDevice, 0);
cuResult = cuCtxCreate(&cu_ctx, 0, cudaDevice);
eglSetupExtensions();
EGLStreamInit();
display = g_display;
streamEGL = eglStream;
cuEGLStreamProducerConnect (&conn, streamEGL, source_width, source_height);
And this is how I want to fill the producer with dummy data:
void* data[3];
cudaMalloc(&data[0],source_width*source_height);
cudaMalloc(&data[1],source_width*source_height/4);
cudaMalloc(&data[2],source_width*source_height/4);
CUeglFrame eglFrame;
eglFrame.width = source_width;
eglFrame.height = source_height;
eglFrame.depth = 1;
eglFrame.pitch = source_width;
eglFrame.planeCount = 3;
eglFrame.numChannels = 1;
eglFrame.frameType = CU_EGL_FRAME_TYPE_PITCH;
eglFrame.eglColorFormat = CU_EGL_COLOR_FORMAT_YUV420_PLANAR;
eglFrame.cuFormat = CU_AD_FORMAT_UNSIGNED_INT8;
eglFrame.frame.pPitch[0] = data[0];
eglFrame.frame.pPitch[1] = data[1];
eglFrame.frame.pPitch[2] = data[2];
CUresult cuStatus = cuEGLStreamProducerPresentFrame(&conn, eglFrame, 0);
if (cuStatus != CUDA_SUCCESS)
std::cout << "cuda Producer present frame FAILED with custatus " << cuStatus << std::endl;
Now this is what I got as result:
eglDisplay Handle created
EGLStream initialized
cuda Producer present frame FAILED with custatus 400
cuda Producer present frame FAILED with custatus 400
cuda Producer present frame FAILED with custatus 400
cuda Producer present frame FAILED with custatus 400
cuda Producer present frame FAILED with custatus 400
cuda Producer present frame FAILED with custatus 400
cuda Producer present frame FAILED with custatus 400
cuda Producer present frame FAILED with custatus 400
cuda Producer present frame FAILED with custatus 400
cuda Producer present frame FAILED with custatus 400
cuda Producer present frame FAILED with custatus 400
cuda Producer present frame FAILED with custatus 400
cuda Producer present frame FAILED with custatus 400
cuda Producer present frame FAILED with custatus 400
cuda Producer present frame FAILED with custatus 400
cuda Producer present frame FAILED with custatus 400
cuda Producer present frame FAILED with custatus 400
cuda Producer present frame FAILED with custatus 400
From documentation I can see that error code 400 refers to CUDA_ERROR_INVALID_HANDLE.
So my question is:
- What could this error mean? the only handles that I give to the function are the CUeglConnection and the CUeglFrame. The connection seems to be fine (cuEGLStreamProducerConnect returns 0) so is there some error with my eglFrame?
- Did I forgot something when initializing EGLStreamKHR?
Unfortunately, I could not find anything about cuEGLStreamProducerPresentFrame but the samples I provided above.