Is there any reason you would not record your screen with an external program? It worked fine for me.
Saving screenshots is possible like described in a github issue. I adopted it for me
def base64_to_image(base64_string: str, output_filename: str):
"""Convert base64 string to image."""
import base64
import os
if not os.path.exists(os.path.dirname(output_filename)):
os.makedirs(os.path.dirname(output_filename))
img_data = base64.b64decode(base64_string)
with open(output_filename, "wb") as f:
f.write(img_data)
return output_filename
...
result = await agent.run()
print(result)
screenshots = result.screenshots()
number_screenshots = 0
for next_screenshot in screenshots:
number_screenshots=number_screenshots+1
path = f"./screenshots/{number_screenshots}.png"
img_path = base64_to_image(
base64_string=str(next_screenshot),
output_filename=path
)
print(img_path)