Encoding grayscale image as h264 with nvvidconv and nvv4l2h264enc incorrect

I am having an identical issue to this one: GRAY8 source with nvvidconv and nvv4l2h264enc produces video with wrong color format (washed out)
where my grayscale image is washed out when using hardware encoding for h264

However, the accepted answer did not work for me. I patched and recompiled nvvidconv as @DaneLLL suggested, but now my output is green instead of gray and still washed out.

Here is my pipeline:
appsrc ! nvvidconv ! nvv4l2h264enc ! video/x-h264,format=byte-stream ! h264parse ! rtspclientsink location=myserver

I’m feeding gstreamer with a grayscale mat from OpenCV, here is the video writer declaration:
writer = cv2.VideoWriter(pipeline, cv.2VideoWriter_fourcc(*'X264'), 30.0, (1920, 1080), False)

I would really like to leverage the hardware acceleration instead of using videoconvert or converting the image to BGR with OpenCV, it is a waste of CPU cycles. Any advice would be appreciated.

Never mind, I’m a moron and copied the wrong code when patching.
DaneLLL’s suggestion worked.

Glad to know issue resolved.

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