Fix streaming
This commit is contained in:
parent
64843c8338
commit
27652682f9
@ -35,7 +35,7 @@ def get_image():
|
|||||||
return Response(content=data.getvalue(), media_type="image/jpeg")
|
return Response(content=data.getvalue(), media_type="image/jpeg")
|
||||||
|
|
||||||
class StreamingOutput(io.BufferedIOBase):
|
class StreamingOutput(io.BufferedIOBase):
|
||||||
def __init(self):
|
def __init__(self):
|
||||||
self.frame = None
|
self.frame = None
|
||||||
self.condition = Condition()
|
self.condition = Condition()
|
||||||
|
|
||||||
@ -66,7 +66,11 @@ async def mjpeg():
|
|||||||
picam2.configure(capture_config)
|
picam2.configure(capture_config)
|
||||||
|
|
||||||
output = StreamingOutput()
|
output = StreamingOutput()
|
||||||
picam2.start_recording(MJPEGEncoder(), FileOutput(output), Quality.VERY_HIGH)
|
encoder = MJPEGEncoder()
|
||||||
|
encoder.output = FileOutput(output)
|
||||||
|
|
||||||
|
picam2.start_recording(encoder, Quality.VERY_HIGH)
|
||||||
|
|
||||||
def stop():
|
def stop():
|
||||||
logging.info("Stopping recording")
|
logging.info("Stopping recording")
|
||||||
picam2.stop_recording()
|
picam2.stop_recording()
|
||||||
@ -74,7 +78,7 @@ async def mjpeg():
|
|||||||
|
|
||||||
return StreamingResponse(
|
return StreamingResponse(
|
||||||
generate_frames(output),
|
generate_frames(output),
|
||||||
media_type="multipart/x-mixed-replace; boundry=frame",
|
media_type="multipart/x-mixed-replace; boundary=frame",
|
||||||
background=BackgroundTask(stop)
|
background=BackgroundTask(stop)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user