@erik .
Hi Erik.
Apart from the issues with FPS and resolution, I have an additional concern. I have disabled the TCP server on one device, leaving it in a bootable state. I am currently experimenting with gen2-RTSP. My objective is to have multiple scripts running for each camera to stream them individually to different endpoints. However, when I run the script for one device, I encounter difficulties streaming from the other device simultaneously. Below is the code I'm using:
#!/usr/bin/env python3
import threading
import gi
gi.require_version('Gst', '1.0')
gi.require_version('GstRtspServer', '1.0')
from gi.repository import Gst, GstRtspServer, GLib
class RtspSystem(GstRtspServer.RTSPMediaFactory):
def __init__(self, **properties):
super(RtspSystem, self).__init__(**properties)
self.data = None
self.launch_string = 'appsrc name=source is-live=true block=true format=GST_FORMAT_TIME ! h265parse ! rtph265pay name=pay0 config-interval=1 name=pay0 pt=96'
def send_data(self, data):
self.data = data
def start(self):
t = threading.Thread(target=self._thread_rtsp)
t.start()
def _thread_rtsp(self):
loop = GLib.MainLoop()
loop.run()
def on_need_data(self, src, length):
if self.data is not None:
retval = src.emit('push-buffer', Gst.Buffer.new_wrapped(self.data.tobytes()))
if retval != Gst.FlowReturn.OK:
print(retval)
def do_create_element(self, url):
return Gst.parse_launch(self.launch_string)
def do_configure(self, rtsp_media):
self.number_frames = 0
appsrc = rtsp_media.get_element().get_child_by_name('source')
appsrc.connect('need-data', self.on_need_data)
class RTSPServer(GstRtspServer.RTSPServer):
def __init__(self, **properties):
super(RTSPServer, self).__init__(**properties)
self.rtsp = RtspSystem()
self.rtsp.set_shared(True)
self.get_mount_points().add_factory("/oak63", self.rtsp)
self.attach(None)
Gst.init(None)
self.rtsp.start()
def send_data(self, data):
self.rtsp.send_data(data)
if __name__ == "__main__":
import depthai as dai
server = RTSPServer()
pipeline = dai.Pipeline()
FPS = 60
colorCam = pipeline.create(dai.node.ColorCamera)
colorCam.setResolution(dai.ColorCameraProperties.SensorResolution.THE_720_P)
colorCam.setInterleaved(False)
colorCam.setColorOrder(dai.ColorCameraProperties.ColorOrder.BGR)
# colorCam.setIspScale(2,3)
# colorCam.setFps(FPS)
videnc = pipeline.create(dai.node.VideoEncoder)
videnc.setDefaultProfilePreset(FPS, dai.VideoEncoderProperties.Profile.H265_MAIN)
colorCam.video.link(videnc.input)
veOut = pipeline.create(dai.node.XLinkOut)
veOut.setStreamName("encoded")
videnc.bitstream.link(veOut.input)
desired_ip = "00.00.00.00
device_infos = dai.DeviceBootloader.getAllAvailableDevices()
device_info = [device_info for device_info in device_infos if device_info.name == desired_ip][0]
if device_info:
if device_info.protocol != dai.XLinkProtocol.X_LINK_USB_VSC:
print("Running RTSP stream may be unstable due to connection... (protocol: {})".format(device_info.protocol))
with dai.Device(pipeline, device_info) as device:
encoded = device.getOutputQueue("encoded", maxSize=30, blocking=True)
print("Setup finished, RTSP stream available under \"rtsp://localhost:8554/oak63\"")
while True:
data = encoded.get().getData()
server.send_data(data)
else
print('No device found')
Further I haven't been able to figure out where am I loosing packages.
need your suggestion how can I achieve desired outcome which is having 60FPS with 1080 Resolution and running different script on different end point in single host.
Thank you very much.
Nikul