36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
|
#!/usr/bin/env python3
|
||
|
import gi
|
||
|
gi.require_version('Gst', '1.0')
|
||
|
gi.require_version('GstRtspServer', '1.0')
|
||
|
from gi.repository import Gst, GstRtspServer, GLib
|
||
|
|
||
|
class CustomRTSPMediaFactory(GstRtspServer.RTSPMediaFactory):
|
||
|
def __init__(self):
|
||
|
super().__init__()
|
||
|
self.set_shared(True)
|
||
|
|
||
|
def do_create_element(self, url):
|
||
|
pipeline = (
|
||
|
"udpsrc port=5600 caps=\"application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H265\" ! "
|
||
|
"rtph265depay ! h265parse ! rtph265pay name=pay0 pt=96"
|
||
|
)
|
||
|
return Gst.parse_launch(pipeline)
|
||
|
|
||
|
class CustomRTSPServer(GstRtspServer.RTSPServer):
|
||
|
def __init__(self):
|
||
|
super().__init__()
|
||
|
factory = CustomRTSPMediaFactory()
|
||
|
mount_points = self.get_mount_points()
|
||
|
mount_points.add_factory("/video", factory)
|
||
|
self.attach(None)
|
||
|
|
||
|
def main():
|
||
|
Gst.init(None)
|
||
|
server = CustomRTSPServer()
|
||
|
loop = GLib.MainLoop() # Updated to GLib
|
||
|
print("RTSP Server running at rtsp://127.0.0.1:8554/video")
|
||
|
loop.run()
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
main()
|