How to seek VideoPlayer to a set position, pause, and take a screenshot?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Fupicat

I’m making a script that helps with rendering video of animations you make on the Godot editor. You make scripts to tell the recorder what to do every frame of the video, then you run the scene and every frame of your animation is saved in your user folder.

(project files with lots of comments at the end of the post)

The “” script is pretty short and works with signals. Every frame, the Recorder node emits a “Recording tick” signal, then waits for every recorded node to send back an “I’m done” signal, and finally takes a screenshot of the viewport.

I’ve already managed to make this work for AnimationPlayer nodes: For every recording tick, just advance a certain number of seconds (1 second / 60 fps) in the current animation.

But for VideoPlayer nodes, this has become confusing. I tried doing that by setting the stream position to a certain time (current frame * (1 second / 60 fps)), but all I get is a black screen, and the output tells me that the stream position of the video stays at 0 the entire time.

I’ve done some digging, and apparently the VideoPlayer node is buggy/unfinished? I didn’t find anything that could explain why I wasn’t able to seek in the video.

Here is the project folder with very commented code:

I tried to make my code as understandable as possible with lots of comments. Here’s a breakdown of the stuff in the project:

  • The “” script is what handles recording ticks and taking
    screenshots. Can be instantiated with “Recorder.tscn”.
  • The “PresetScripts/” script is a working example of a
    script that uses the signals from a Recorder node to advance an
    AnimationPlayer node every recording tick. Can be tested at
  • The “PresetScripts/” script is the one that is not
    working. It’s supposed to use the signals from a Recorder node to
    advance a VideoPlayer node every recording tick. Can be tested at “Tests/VideoPlayer/VideoPlayer.tscn”.