Hardware video encoder vs software encoder

On my AGX running JP 4.6.1, I have a series of png files (PNG image data, 1296 x 972, 8-bit grayscale, non-interlaced) that I am trying to create rtsp stream. I tried both hardware and software encoder:

test-launch 'multifilesrc location="%07d_0.png" caps="image/png,framerate=13/1" ! pngdec ! nvvidconv ! video/x-raw(memory:NVMM),format=(string)I420 ! nvv4l2h265enc ! rtph265pay name=pay0 pt=96'

test-launch 'multifilesrc location="%07d_0.png" caps="image/png,framerate=13/1" ! pngdec ! videoconvert ! video/x-raw,format=(string)I420 ! x265enc ! rtph265pay name=pay0 pt=96'

On a test client (Debian 11), I tried to capture the rtsp stream and save back to png files, just to see how they compare to the original png files on the AGX.

gst-launch-1.0 -e rtspsrc location=rtsp://agx:8554/test protocols=tcp ! decodebin ! queue ! videoconvert ! video/x-raw,format=GRAY8 ! pngenc ! multifilesink location="images_%07d.png"

When I open the resulting png files and check them visually to compare to the original png files, I can see :

  1. when using hardware encoder, the resulting images seems much lighter gray. I tried adding property “enable-lossless=true” to nvv4l2h265enc, but that doesn’t make a difference.
  2. when using software encoder, the darkness level seems to match very well.

Anything I can tune the hardware encoder so that I can have same level of darkness, like the software encoder?

Hi,
Not sure but probably the PNG file is encoded from GRAY in full range [0, 255], not limited range [16,235]?

Yes, I think they are in full range. Are you saying only software encoder can properly handle full range?

Following the suggestion from here, I took the nvvidconv source from https://developer.nvidia.com/embedded/l4t/r32_release_v7.1/sources/t186/public_sources.tbz2

sed -i .orig 's/NvBufferColorFormat_YUV420/NvBufferColorFormat_YUV420_ER/g' \
  gstnvvconv.c

rebuilt and replaced libgstnvvidconv.so on the camera. After clearing the gstreamer cache and rerunning the pipeline, I don’t see any improvement.

Hi,
Please try to convert GRAY8 to I420 through videoconvert plugin:

test-launch 'multifilesrc location="%07d_0.png" caps="image/png,framerate=13/1" ! pngdec ! videoconvert ! video/x-raw,format=(string)I420 ! nvvidconv ! video/x-raw(memory:NVMM),format=(string)I420 ! nvv4l2h265enc ! rtph265pay name=pay0 pt=96'

That works! The dark level matches now.
But I also notice the cpu usage on the AGX bumped up from 17% to 30-34%.

Hi,
Seems like the GRAY8 is in full range [0,255]. In nvvidconv plguin, it allocates NvBuffer in NvBufferColorFormat_GRAY8, which is in limited range [16,235].

Is it possible to fix nvvidconv plugin to support the full range? Using the software plugin unnecessarily bump up the cpu usage.

I tried your other suggestion as menteioned here to compile a new nvvidconv plugin, but that didn’t help.

Hi,
We would need to check if we can include this use-case in next release. On the existing releases, please use videoconvert plugin for the conversion.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.