Open pteran2403 opened 1 year ago
Hi @pteran2403,
You can run this python script to start the server and stearm the data. You can also run this as a system service or cron job in the backgroud.
I am running it in the background as a service but I would like to keep the RTSP running in the background without the need of calling the rtsp. I know I have to so add a ( udpsrc port=5400 name=pay0 caps=\"application/x-rtp, media=video, clock-rate=90000, encoding-name=(string)H264, payload=96 \
but I dont know where to put my opencv injector code
I tried:
import gi
gi.require_version('Gst', '1.0')
gi.require_version('GstRtspServer', '1.0')
from gi.repository import Gst, GstRtspServer, GLib, GObject
Gst.init([])
def create_rtsp_server():
server = GstRtspServer.RTSPServer.new()
server.set_property("service", "8554")
server.attach(None)
factory = GstRtspServer.RTSPMediaFactory.new()
pipeline = "( udpsrc port=5400 name=pay0 caps=\"application/x-rtp, media=video, clock-rate=90000, encoding-name=(string)H264, payload=96 \" )"
factory.set_launch(pipeline)
factory.set_shared(True)
server.get_mount_points().add_factory("/stream", factory)
def process_video(path):
pipeline = Gst.parse_launch(f" filesrc location={path} \
! decodebin \
! nvvideoconvert \
! nvv4l2h264enc \
! h264parse \
! rtph264pay \
! udpsink host=127.0.0.1 port=5400 sync=true async=false ")
create_rtsp_server()
pipeline.set_state(Gst.State.PLAYING)
loop = GLib.MainLoop.new(None, False)
loop.run()
process_video("path/to/mp4/video.mp4")
Hi @prabhakar-sivanesan Awesome project, I have a question, I noticed the RTSP stream only starts when a connection is made. For example, only starts when I connect to the stream via VLC and stops when I stop the stream (or close VLC). How can I make the rtsp server run in the backgroud without having to open VLC?
I added the following line but doesn't seem to make a difference:
.set_state(Gst.State.PLAYING)