I know what can be used to open the result in the desired template.
return render(request, 'video_feed.html', {'video_feed': generate()})
But I have a video stream and this option is not applicable to it.
return StreamingHttpResponse(generate(), content_type='multipart/x-mixed-replace; boundary=frame')
How can I make it so that the video stream does not open in full screen, but fits into a certain template?
Thank you
from django.http import StreamingHttpResponse
from django.views.decorators import gzip
from .object_counter import CountObject, VideoCapture
import cv2
# Create an instance of CountObject and VideoCapture
rtsp_url = "rtsp://.../cam/realmonitor?channel=1&subtype=00&authbasic=[AUTH]"
count_object_instance = CountObject(rtsp_url)
video_capture = VideoCapture(rtsp_url)
@gzip.gzip_page
def video_feed(request):
def generate():
while True:
frame = video_capture.read()
annotated_frame = count_object_instance.process_frame(frame)
_, buffer = cv2.imencode('.jpg', annotated_frame)
frame_bytes = buffer.tobytes()
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame_bytes + b'\r\n')
return StreamingHttpResponse(generate(), content_type='multipart/x-mixed-replace; boundary=frame')