CUDA fail when ffmpeg decode H264 and gstreamer encode mp4 file

Ah ok, gotcha - the memory would need to be allocated on GPU. Try using the cudaAllocMapped() function - this will allocate memory that is shared between the CPU and GPU (since Jetson shares the same physical memory between the CPU/GPU, it can use zero-copy memory).

If you image is in another buffer, you can do a simply memcpy() to the buffer you allocate with cudaAllocMapped(), since the cudaAllocMapped() pointer is accessible from both the CPU and GPU. Then pass that pointer from cudaAllocMapped() to gstEncoder::Render().