Write a VideoΒΆ
By adding a few lines, you can record an in-game video.
First, add as the last line in the draw() function in main.py:
return frame
Second, add in main.py before the while loop:
fourcc = cv2.VideoWriter_fourcc(*"MP4V")
out = cv2.VideoWriter("myvideo.mp4", fourcc,
60.0, # frames per second
(SCREEN_SIZE_X,SCREEN_SIZE_Y)
)
Finally, replace the call to draw() inside the while loop with:
frame = draw(game, images, moves)
out.write(frame)
Run the code and see if a video gets written.