encode h264 video stream from IPC. The delay is too large compared to the original flow.

I’m coding h264 with nvencoder, and I see a delay of 300 milliseconds, so how do I minimize the delay. Minimize the first frame.
Pull h264 video stream from ipc. the first decode the original video stream,the second.encode into a new h264 video stream.Finally,to play, the total delay time is 300 milliseconds compared to the original camera stream.