Hi,
There is a sample of saving to MP4:
Displaying to the screen with OpenCV and GStreamer - #9 by DaneLLL
You may give it a try and see if it works. Some users have mentioned it triggers some issue without a space at the end of pipeline, so you may try
"... ! udpsink host=127.0.0.1 port=5400 async=false " (add a space after async=false)