How to Render The Game to PNG Animation Frames?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By davidpgil
:warning: Old Version Published before Godot 3 was released.

I want to render my game to image animation frames using a cheat code. This is what I am imagining:

  1. Start Game and execute cheat code, like hold “R” key.
  2. For every frame that the game is running, save to a subfolder of my game folder called “_render_frames” on my computer.

How would I go about creating this?

Rendering every frame this way might take a bit too long, maybe you could use a screen recording software?

Zylann | 2017-11-16 01:52

Rendering every frame this way might take a bit too long, maybe you
could use a screen recording software?

Why would it take too long? I have my reasons for rendering out actual frames of my project. I am aware there are screen recorders that can do this. However, I don’t want a screen recorder for this task. I want the frame output to indicate actual frames in my project.

davidpgil | 2017-11-17 15:57

It may take too long because the engine is not designed to do this. You can see this straight away with the take_screenshot API, you will see it waits before giving you the resulting image: Viewport — Godot Engine (stable) documentation in English

That’s because doing this, you are asking the renderer to lock the current frame and download it back to CPU side, which may stall rendering.
I also believe screen recorders use a specific driver to accomplish this in realtime, which Godot doesn’t use anyways because the engine isn’t designed for this.

You may try though, see if you get all frames. I’d be curious to know if it works.

Zylann | 2017-11-17 19:45

:bust_in_silhouette: Reply From: David Krause

This might help:
https://forum.godotengine.org/12164/as-in-the-game-to-take-a-screenshot