0 votes

This script is supposed to seek a VideoPlayer's stream to a position, then pause it, and tell another node called “Recorder” to take a screenshot and save it to your user folder. After taking the screenshot, this cycle repeats.

But for some reason, this code does nothing, the VideoPlayer's stream just stays at position 0. Can someone who knows more about VideoPlayer help me out?

extends VideoPlayer

signal im_done

export var recorder_path : NodePath = '../Recorder'

# Get recorder node from path provided by the user.
onready var recorder = get_node(recorder_path)

func _ready():
    add_to_group('RecordThis')
    var _err = recorder.connect("recording_tick", self, "recording_tick")
    _err = recorder.connect("recording_start", self, "recording_start")
    _err = connect("im_done", recorder, "check_done")

# Called at the beginning of the recording.
func recording_start():
    play()

# Called every frame of the recording.
func recording_tick(delta):
    paused = false
    play()

    # Jump to the second that equals “current frame number * delta”.
    # Delta = 1 second / X frames per second. Ex: for 60fps, delta = 0.016667
    set_stream_position(recorder.frame * delta)

    # Uncomment this to see: the stream_position is always 0.
    #print(stream_position)

    paused = true

    # Tell the recorder your frame is finished.
    emit_signal("im_done")

If you want to test you can download the project file here. Press HOME to start the recording and press END to abort it.

You can run the scene “Tests/AnimationPlayer/AnimationPlayer.tscn” to see a working example of what I'm trying to achieve that uses AnimationPlayers instead of VideoPlayers.

in Engine by (85 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.