Use gpu with gstreamer

Hello, I have a Jetson Nano connected to 4 USB cameras. I use GStreamer to capture video from these cameras. I’ve seen that there are different settings that allow encoding/decoding to use the GPU. I’ve tried various mods, but the GPU is never used.

I use the command “tegrastats” and it always shows this: GR3D_FREQ 0%@921.

Hi @efren.codesoctag

Could you share the GStreamer pipeline you are using? To use the GPU you should use the GStreamer elements that can access the GPU for example the nvv4l2h264enc

Regards,

Enrique Ramirez
Embedded SW Engineer at RidgeRun
Contact us: support@ridgerun.com
Developers wiki: https://developer.ridgerun.com
Website: www.ridgerun.com

I am currently using this command:

gst-launch-1.0 -v v4l2src device=/dev/video0 do-timestamp=true !
image/jpeg,width=1920,height=1080,framerate=30/1 ! nvjpegdec ! nvvidconv ! nvv4l2h264enc maxperf-enable=1 iframeinterval=30 bitrate=3000000 insert-sps-pps=1 ! ‘video/x-h264, stream-format=(string)byte-stream’ ! rtph264pay mtu=1000 ! udpsink host=192.168.1.100 port=5000 > gst_command_0.log 2>&1 &

I have read that nvjpegdec, nvvidconv, and nvv4l2h264enc with maxperf-enable=1 help optimize GPU usage. However, when I run these commands, the only thing I see is that each of the 4 processes from each camera uses more CPU (over 90%).

Previously, I was using this (without nvjpegdec), and each process used less CPU, which I don’t understand:

gst-launch-1.0 -v v4l2src device=/dev/video0 do-timestamp=true ! image/jpeg,width=1920,height=1080,framerate=30/1 ! jpegdec ! videoflip method=0 ! nvvidconv ! nvv4l2h264enc maxperf-enable=1 iframeinterval=30 bitrate=3000000 insert-sps-pps=1 ! ‘video/x-h264, stream-format=(string)byte-stream’ ! rtph264pay mtu=1000 ! udpsink host=192.168.1.100 port=5000 > gst_command_3.log 2>&1 & echo

Hi,
There are individual hardware codec engines in Jetson chips. Please run sudo tegrastats and you will see status of NVENC and NVDEC engines.

Yes, I can see those two fields appear. But each process uses a lot of CPU, I thought the GPU could reduce its use more.

In this screenshot, GR3D_FREQ is 0% and four gst processes are running.

Hi,
Please try nvv4l2decoder mjpeg=1 to decode JPEG:

$ gst-launch-1.0 -v v4l2src device=/dev/video0 do-timestamp=true ! image/jpeg,width=1920,height=1080,framerate=30/1 ! nvv4l2decoder mjpeg=1 ! ...