rtsp_fastapi
rtsp_fastapi copied to clipboard
If i want to stream multiple rtsp urls on a same web page in the form a grid how can i do that
Hi @hemantdawn
Yes! There are some way to do that. In my case, I would change the variable "manager" to receive a empty dict like:
manager = {}
And you will need pass the number of each cam to receive the stream.
When you call the function video_feed, you need pass the cam on URL:
def streamer(cam_id):
try:
while manager[cam_id]:
yield (b'--frame\r\n' b'Content-Type: image/jpeg\r\n\r\n' +
bytearray(manager[cam_id].get()) + b'\r\n')
except GeneratorExit:
print("cancelled")
@app.get("/{cam_id}")
async def video_feed(cam_id: int):
return StreamingResponse(streamer(cam_id), media_type="multipart/x-mixed-replace;boundary=frame")
See if these examples help. If you need more help, I can update the repo with a complete code.
Hi @hemantdawn
Yes! There are some way to do that. In my case, I would change the variable "manager" to receive a empty dict like:
manager = {}
And you will need pass the number of each cam to receive the stream.
When you call the function video_feed, you need pass the cam on URL:
def streamer(cam_id): try: while manager[cam_id]: yield (b'--frame\r\n' b'Content-Type: image/jpeg\r\n\r\n' + bytearray(manager[cam_id].get()) + b'\r\n') except GeneratorExit: print("cancelled") @app.get("/{cam_id}") async def video_feed(cam_id: int): return StreamingResponse(streamer(cam_id), media_type="multipart/x-mixed-replace;boundary=frame")
See if these examples help. If you need more help, I can update the repo with a complete code.
Hi @mpimentel04, can you please update the repo for this issue? Thank you.