How to stream camera by UDP H264

Sorry I missed that (I’m more familiar with gstreamer for such case).
You would use the sdp file as well :

setenv ("OPENCV_FFMPEG_CAPTURE_OPTIONS", "protocol_whitelist;file,rtp,udp", 1);
cap = cv::VideoCapture("test.sdp", cv::CAP_FFMPEG);