I copied a script from adaftut which allows to show the camera stream on the TFT LCD. However using that stream I cannot save the camera recording.
The script opens io.BytesIO, than gets the camera captures into that stream and than closes the stream in while loop. And I cannot save the stream as a video. This is part of the code:
while(True):
stream = io.BytesIO() # Capture into in-memory stream
camera.capture(stream, use_video_port=True, format='raw')
stream.seek(0)
stream.readinto(yuv) # stream -> YUV buffer
stream.close()
yuv2rgb.convert(yuv, rgb, sizeData[sizeMode][1][0],
sizeData[sizeMode][1][1])
img = pygame.image.frombuffer(rgb[...], 'RGB')
Can you please help to save the stream as a recording? I need both to save camera recording and to preview camera data on LCD TFT.