Reliable video streaming?

I am trying to get a smooth camera stream from my Raspberry Pi 3B camera (Camera Module 3) to a server. I started out trying libcamera over TCP however the stream was jumping and the framerate was fluctuating quite a lot. I then tried MediaMTX over RTSP and that seems to be a bit smoother however the framerate still fluctuates so the video appears to change in speed quite regularly. I need the stream to be as consistent as possible as I am estimating vehicle speed based on the distance a vehicle travels over time. I am using the H.264 codec and viewing the stream in VLC on the server.