Stream a webcam video processing with OpenCV on a network with UDP

Hi!

I’m trying to get the video stream from my webcam and send it over my network. I want to do this with OpenCV because I plan to do some image processing with the webcam and I would just like to send the webcam stream processed with OpenCV directly to my network.
To start with, I try to send it directly to my computer where I do the processing.

I wrote this code :

#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/aruco.hpp>
#include <opencv2/core/types.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/gapi.hpp>

#include <iostream>

using namespace std;
using namespace cv;

int main(int argc, char* argv[])
{
  cv::VideoCapture inputVideo; //to open video flux
  inputVideo.open(0);
  int frame_width = inputVideo.get(cv::CAP_PROP_FRAME_WIDTH);
  int frame_height = inputVideo.get(cv::CAP_PROP_FRAME_HEIGHT);
  int fps = inputVideo.get(cv::CAP_PROP_FPS);

  cv::VideoWriter outputVideo("appsrc ! videoconvert ! video/x-raw ! x264enc ! rtph264pay ! udpsink host=127.0.0.1 port=5000",cv::CAP_GSTREAMER,0,fps,cv::Size(frame_width,frame_height), true);

  while (inputVideo.grab())
  {
	    cv::Mat image, imageCopy;

      	inputVideo.retrieve(image);
    	outputVideo.write(image);

    	cv::imshow("out", image);
    	char key = (char) cv::waitKey(10);
    	if (key == 27)
        	break;
  }

  inputVideo.release();
  outputVideo.release();

 return 0;
}

The code compiles and I have the return of the webcam done by cv::imshow. The only warning I get is the following but I didn’t manage to fix it.

And when I open VLC > Media > Open Network Stream and I enter udp://@:5000 I can’t get the webcam stream, nothing happens. VLC doesn’t retrieve anything.
I am on OpenCV version 4.5.5.

I’m really not sure if I’m doing it the right way.
Do you have any ideas?

Thanks