DO NOT MERGE: BMP video capture

Capture the last two seconds of video to bmp files
This commit is contained in:
Correl Roush 2020-09-26 23:38:27 -04:00
parent 10b95738e8
commit 21fd4cf75e

View file

@ -174,6 +174,7 @@ def main():
app.run() app.run()
clock = pygame.time.Clock() clock = pygame.time.Clock()
title = "<Idle>" title = "<Idle>"
frames = deque(maxlen=60 * 2)
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == QUIT or ( if event.type == QUIT or (
@ -182,6 +183,14 @@ def main():
app.shutdown() app.shutdown()
pygame.quit() pygame.quit()
return return
if event.type == KEYDOWN and event.key == K_v:
for frame, s in enumerate(frames):
pygame.image.save(
pygame.image.fromstring(
s, (screen.get_width(), screen.get_height()), "RGB"
),
"turntable-{:04d}.bmp".format(frame),
)
try: try:
while event := event_queue.get(False): while event := event_queue.get(False):
... ...
@ -208,6 +217,7 @@ def main():
title_rect.centery = screen.get_height() - 25 title_rect.centery = screen.get_height() - 25
screen.blit(title_text, title_rect) screen.blit(title_text, title_rect)
pygame.display.update() pygame.display.update()
frames.append(pygame.image.tostring(screen, "RGB"))
clock.tick(FPS) clock.tick(FPS)
except: except:
logger.exception("Shutting down") logger.exception("Shutting down")