How to implement gst timeoverlay element like feature over nvv4l2camerasrc and nv encoder elements?

I’d like to add predefined string and timestamp string over every frame captured by nvv4l2camerasrc.
I know that the frame data has caps of “video/x-raw(memory:NVMM)” and If I use timeoverlay, the frame data needs to be converted to normal “video/x-raw” and it is not efficient.

Which way is the most efficient to implement such feature over nvv4l2camerasrc and nv encoder elements which transfer “video/x-raw(memory:NVMM)” frame data?

You may leverage DeepStream plugin nvdsosd. A sample pipeline:

$ gst-launch-1.0 videotestsrc ! nvvideoconvert ! nvdsosd display-clock=1 ! nvoverlaysink

For using nvv4l2camerasrc, please try

$ gst-launch-1.0 nvv4l2camerasrc bufapi-version=1  ! nvvideoconvert ! nvdsosd display-clock=1 ! nvoverlaysink