Last active
March 18, 2019 14:31
-
-
Save marcosbitetti/8b37d2181cc462ebc5413936dd9c4bbb to your computer and use it in GitHub Desktop.
Godot 3.x frame render to video editor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################## | |
# | |
# Author: NerdOfTheMountain (Marcos A. Biteti - https://github.com/marcosbitetti) | |
# | |
# This work is licensed under a Creative Commons Attribution 4.0 International License. | |
# | |
# USAGE: | |
# 1. Attach this script in a AnimationPlayer node | |
# 2. Set animation name and optionally framerate in properties editor | |
# 3. In project setthings choose: fullscreen = true, stretch mode = viewport and apect=igonre | |
# 4. In user folder create a folder called "render" to store all image files | |
# it's usually: | |
# mac/linux: ~/.local/share/godot/app_userdata/_application_name_/ | |
# win : C:\Users\<username>\AppData\Roaming\Godot\app_userdata\<project>\ | |
# 5. Run game to generate a frame sequence, and import it in a video editor software | |
# 6. Enjoy | |
# | |
############################################## | |
extends AnimationPlayer | |
export(String) var animation | |
export(int) var fps = 30 | |
var time = 0.0 | |
var frame = 0 | |
func _process(delta): | |
if time<current_animation_length: | |
frame += 1 | |
var img = get_viewport().get_texture().get_data() | |
img.flip_y() | |
img.save_png("user://render/" + str(frame).pad_zeros(6) + ".png") | |
seek(time,true) | |
time += 1.0/float(fps) | |
else: | |
get_tree().call_deferred( "quit" ) | |
func _ready(): | |
if animation: | |
stop() | |
current_animation = animation | |
else: | |
set_process(false) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment