How to publish images to an rtsp server?

I’m currently trying to run a setup where I have a locally hosted rtsp server, to which I want to publish images to that my client which would be deepstream can access it and perform the usual pipeline operations. The place where I’m currently struggling is publishing part,

ffmpeg -re -stream_loop -1 -i file.ts -c copy -f rtsp rtsp://localhost:8554/mystream

The above command serves the local file on the rtsp server which I’m hosting. Any idea as to how to achieve the same task using images?

We see a plugin rtpjpegpay:

We have h264 and h265 encoding in deepstream-app. You would need to customize the app to run jpeg encoding.

@DaneLLL, hey I’m currently working half way through replicating something similar, can you please let me know where the error is, I’m able to see frames on the receiver end when running a gst pipline to read udp source. I would like to attach the port I’m writing to a RTSP server. The code is attached below,
sender.cpp (1.8 KB) Could you please take a look at it and help me as to where I’m going wrong? Thanks.

#include <iostream>
#include <gst/rtsp-server/rtsp-server.h>
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"

using namespace std;
using namespace cv;

int main()
GstRTSPServer *server;
GstRTSPMountPoints *mounts;
GstRTSPMediaFactory *factory;

char port_num_Str[64] = { 0 };
char udpsrc_pipeline[512];
sprintf (port_num_Str, "%d", 8554);

server = gst_rtsp_server_new ();
g_object_set (server, "service", port_num_Str, NULL);
mounts = gst_rtsp_server_get_mount_points (server);
factory = gst_rtsp_media_factory_new ();

sprintf (udpsrc_pipeline,
  "( udpsrc name=pay0 port=%d caps=\"application/x-rtp, media=video, "
  "clock-rate=90000, encoding-name=JPEG, payload=96 \" )",

  // gst-launch-1.0 -v udpsrc port=5000 \
  // ! application/x-rtp, media=video, clock-rate=90000, encoding-name=JPEG, payload=26 \
  // ! rtpjpegdepay \
  // ! jpegdec \
  // ! xvimagesink sync=0

gst_rtsp_media_factory_set_launch (factory, udpsrc_pipeline);
gst_rtsp_mount_points_add_factory (mounts, "/test", factory);
g_object_unref (mounts);
gst_rtsp_server_attach (server, NULL);

VideoCapture cap("videotestsrc ! video/x-raw,format=BGR,width=640,height=480,framerate=30/1 ! appsink",CAP_GSTREAMER);

VideoWriter out("appsrc ! videoconvert ! video/x-raw,format=YUY2,width=640,height=480,framerate=30/1 ! jpegenc ! rtpjpegpay ! udpsink host= port=5000",CAP_GSTREAMER,0,30,Size(640,480),true);

if(!cap.isOpened() || !out.isOpened())
    cout<<"VideoCapture or VideoWriter not opened"<<endl;

Mat frame;

while(true) {;