0

Want to implement a custom plugin which process only the GPU frames (memory:CUDAMemory) and also update the frame (Consider creating an overlay on the video).

$./gst-launch-1.0 videotestsrc ! cudaupload ! 'video/x-raw(memory:CUDAMemory)' ! **myplugin** ! cudascale ! cudadownload ! autovideosink
/* chain function
 * this function does the actual processing
 */
static GstFlowReturn
gst_test_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{
  GstTest *filter;

  filter = GST_TEST (parent);

  if (filter->silent == FALSE)
    g_print ("I'm plugged, therefore I'm in.\n");

  GstMemory *mem;
  if (gst_buffer_n_memory (buf) == 1 &&
      (mem = gst_buffer_peek_memory (buf, 0)) && gst_is_cuda_memory (mem)) {
    //Issue: gst_is_cuda_memory failed here
      
      GstCudaMemory *cmem = GST_CUDA_MEMORY_CAST (mem);
      
      //TODO Do processing
      
  }

  /* just push out the incoming buffer without touching it */
  return gst_pad_push (filter->srcpad, buf);
}

So, I set gst_pad_set_chain_function to sinkpad and getting GstBuffer data one by one, but when I try to Convert GstBuffer to GstCudaMemory then We got this error message.

(gst-launch-1.0:47481): GLib-GObject-WARNING **: 18:20:20.641: cannot register existing type 'GstCudaAllocator'
(gst-launch-1.0:47481): GLib-CRITICAL **: 18:20:20.641: g_once_init_leave: assertion 'result != 0' failed

Any idea how to process with CUDA memory buffer ?

0 Answers0