How to use CUDA in gstreamer pipeline

hi everyone!
i am using:
TX2
Release 28.2
i have a gstreamer pipeline:
"( appsrc name=mysrc ! h264parse ! omxh264dec ! nvvidconv ! video/x-raw(memory:NVMM), width=%d, height=%d, format=I420 ! omxh264enc temporal-tradeoff==1 control-rate=1 bitrate=%d peak-bitrate=%d ! video/x-h264, profile=baseline ! rtph264pay pt=96 name=pay0 "

( i have more c code behind …)

i read that i can use CUDA to get best performance .
i dont know how to do that.
i try
"( appsrc name=mysrc ! h264parse ! omxh264dec ! videocuda ! video/x-raw(memory:NVMM), width=%d, height=%d, format=I420 ! omxh264enc temporal-tradeoff==1 control-rate=1 bitrate=%d peak-bitrate=%d ! video/x-h264, profile=baseline ! rtph264pay pt=96 name=pay0 "

and try :

"( appsrc name=mysrc ! h264parse ! omxh264dec ! nvivafilter cuda-process=true customer-libname=libnvsample_cudaprocess.so ! video/x-raw(memory:NVMM), width=%d, height=%d, format=I420 ! omxh264enc temporal-tradeoff==1 control-rate=1 bitrate=%d peak-bitrate=%d ! video/x-h264, profile=baseline ! rtph264pay pt=96 name=pay0 "

but no success…
someone know how to do that ?

Not sure what you mean by getting better performance.
You initial pipeline just decodes H264 stream, rescales and re-encodes into H264 baseline profile before RTSP streaming. omx plugins do encoding and decoding with dedicated HW NVENC and NVDEC.

If you mean having a custom processing with CUDA between decoding and encoding, yes nvivafilter may be an option for using GPU.
Download the public_sources tarball from NVIDIA developer (being logged) then extract tarball nvsample_cuda_process_src.tbz2, and you’ll get the sources)
You may provide the absolute path to customer-libname. Be aware that if the lib is not found, it may silently fallback to default lib doing nothing in gpu_process.

You may further tell what kind of processing you want to do for better advice.

my question how do i need to use it?

do i need the “nvvidconv” for scaling ?
just put the

nvivafilter cuda-process=true customer-libname=libnvsample_cudaprocess.so

between encode and video/x-raw(memory:NVMM)?
can you help me how to write right my pipeline with the nvivafilter ?
thank you Honey_Patouceul

nvivafilter doesn’t rescales. It is a filter. It requires input and output buffers in NVMM memory. It prepares output buffer by converting color from input format to ouput format if different, then you can process the ouput buffer in place for any modification. The processing would be done in RGBA or I420/NV12 depending on your output format.

I may not help much for pure CUDA processing, but for using CUDA from opencv, you may have a look to these examples:
RGBA processing

NV12 format processing: