Hi everyone I have problem with RTSP live streaming
Here is code of stream :
def stream_rtsp(request, rtsp_id):
port, id = rtsp_id.split()
rtsp_url = f'rtsp://{GLOBAL_IP}:{port}/{id}'
cap = cv2.VideoCapture(rtsp_url)
print('camera opened')
def video_stream():
while True:
ret, frame = cap.read()
if not ret:
break
# print('framing')
target_size = (960, 720)
frame = cv2.resize(frame, target_size)
_, buffer = cv2.imencode('.jpg', frame)
send_event('test', 'rtsp', {'buffer': buffer.tobytes()})
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + buffer.tobytes() + b'\r\n')
cap.release()
return StreamingHttpResponse(video_stream(), content_type="multipart/x-mixed-replace; boundary=frame")
Is there any ways to did it? Channels? Or maybe you already have that kind of problem how you solve it?