Custom gstreamer plugin to draw OSD using L4T nvosd.h

Hi all,

I’m developing a OSD drawing gstreamer plugin for Jetson camera. My expected pipeline is:

gst-launch-1.0 nvarguscamerasrc ! video/x-raw\(memory:NVMM\),width=1932,height=1090,format=NV12,framerate=30/1 \
    ! nvvidconv ! video/x-raw\(memory:NVMM\),format=RGBA \
    ! myosd ! fakesink

I plan to use nvosd.h APIs in myosd custom plugin. But don’t have any idea to connect the DMA buffer fd (needed by nvosd APIs) and NVMM memory (can be gotten from GstBufer in transform_ip plugin function?)

Can you please share some clues to:

  • get GPU image buffer from GstBuffer
  • get DMABUF FD from GPU image or GstBuffer
  • Can cuda process function via nvivafilter plugin get metadata from pipeline?

Thank you for sharing.

The nvvidconv plugin is open source from JP4.5. You can add a property like enable_myosd and the code in the plugin to run like

gst-launch-1.0 nvarguscamerasrc ! video/x-raw\(memory:NVMM\),width=1932,height=1090,format=NV12,framerate=30/1 \
    ! nvvidconv enable_myosd=1 ! video/x-raw\(memory:NVMM\),format=RGBA \
    ! fakesink

The source code is in


Hi @DaneLLL,
Thank you for that very useful info. It is so good that NVIDIA open nvvidconv’s source. We can learn a lot from the source.

1 Like

Hi @DaneLLL ,

After read code of nvvidconv, I apply the similar for my custom OSD plugin and it works now. But still have some questions:

  1. The display_text and font_name strings in text parameter will be freed automatically after OSD draw (in nvosd_put_text function’s param)? Or this should be managed by myself?
  2. nvosd_set_clock_params() fills the text param, then need to use nvosd_put_text() to draw the OSD? I got warning regarding display_text field when using set_clock_params. Do you have any example where nvosd_set_clock_params function is used?
  3. Can nvosd_put_text() work with YUV/NV12 pixel format in new JP?

Thank you.

There is a patch for your reference:
Unable to display text using nvosd_put_text() - #4 by WayneWWW
It does not work with YUV420/NV12. Please convert to RGBA.

And please share the warning print in calling nvosd_set_clock_params().

Hi @DaneLLL ,

Thank you. I have seen that patch (in video decode cuda example), I apply the same for my code. I concern about the strdup function is used every time the frame is de-queued. That means on every video frame, the string will be allocated a new memory for OSD drawing. The question is, after OSD is drawn, does the nvosd free those string memory automatically?

Regard nvosd_set_clock_params, I have done experiments and found that this function is independent with nvosd_put_text. So I can draw clock on my video frame now. But how can I specify the datetime format for nvosd_set_clock_params?

The datetime format is fixed to Year-Month-Day Hour:Min:Sec and not able to be changed.

1 Like

Is this myosd a separate library?
Is it possible to call nvosd_put_text function directly from nvvdiconv sources?

Hi dev.ivan.h,

Please help to open a new topic with more details of your issue. Thanks

Looks like we already solved out problem.
Thanks for your help.