h264 instead

This commit is contained in:
Alex 2024-12-16 13:08:14 -04:00
parent 92d3a6b2ec
commit f273630bc7

View File

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