Compressing rtsp video to h264 on jetson orin nx using gstreamer

I am trying to run gstreamer in my program, and compress it to h264.
My main goal is to publish each frame in ros2 environment so I will be able to perform any processing locally and publish the processed image compressed. currently I cannot seem to compress it properly and flood my network

this is my pipeline:

        pipeline_str = (
            f"rtspsrc location={self.source} latency=60 ! "
            "rtph264depay ! h264parse ! nvv4l2decoder ! nvvidconv ! "
            "video/x-raw(memory:NVMM), format=NV12, width=320, height=240 ! "
            "nvv4l2h264enc bitrate=2000000 maxperf-enable=1 ! h264parse ! "
            "appsink name=appsink drop=false sync=false emit-signals=true max-buffers=10"
        )

and I publish the frame as data of a custom message and not using ros2 Image msg

Hi,
You have enabled max performance mode to nvv4l2h264enc. Please also enable max performance mode to nvv4l2decoder and see if there is enhancement. And may run $ sudo jetson_clocks to enable the system in max performance.

I tried, not working either.