MovieWriter

package
v0.0.0-...-fa94a0d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2025 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Godot can record videos with non-real-time simulation. Like the --fixed-fps command line argument, this forces the reported delta in Node.Process functions to be identical across frames, regardless of how long it actually took to render the frame. This can be used to record high-quality videos with perfect frame pacing regardless of your hardware's capabilities.

Godot has 3 built-in MovieWriters:

- OGV container with Theora for video and Vorbis for audio (.ogv file extension). Lossy compression, medium file sizes, fast encoding. The lossy compression quality can be adjusted by changing ProjectSettings "editor/movie_writer/video_quality" and ProjectSettings "editor/movie_writer/ogv/audio_quality". The resulting file can be viewed in Godot with VideoStreamPlayer and most video players, but not web browsers as they don't support Theora.

- AVI container with MJPEG for video and uncompressed audio (.avi file extension). Lossy compression, medium file sizes, fast encoding. The lossy compression quality can be adjusted by changing ProjectSettings "editor/movie_writer/video_quality". The resulting file can be viewed in most video players, but it must be converted to another format for viewing on the web or by Godot with VideoStreamPlayer. MJPEG does not support transparency. AVI output is currently limited to a file of 4 GB in size at most.

- PNG image sequence for video and WAV for audio (.png file extension). Lossless compression, large file sizes, slow encoding. Designed to be encoded to a video file with another tool such as FFmpeg after recording. Transparency is currently not supported, even if the root viewport is set to be transparent.

If you need to encode to a different format or pipe a stream through third-party software, you can extend the MovieWriter class to create your own movie writers. This should typically be done using GDExtension for performance reasons.

Editor usage: A default movie file path can be specified in ProjectSettings "editor/movie_writer/movie_file". Alternatively, for running single scenes, a movie_file metadata can be added to the root node, specifying the path to a movie file that will be used when recording that scene. Once a path is set, click the video reel icon in the top-right corner of the editor to enable Movie Maker mode, then run any scene as usual. The engine will start recording as soon as the splash screen is finished, and it will only stop recording when the engine quits. Click the video reel icon again to disable Movie Maker mode. Note that toggling Movie Maker mode does not affect project instances that are already running.

Note: MovieWriter is available for use in both the editor and exported projects, but it is not designed for use by end users to record videos while playing. Players wishing to record gameplay videos should install tools such as OBS Studio or SimpleScreenRecorder instead.

Note: MJPEG support (.avi file extension) depends on the jpg module being enabled at compile time (default behavior).

Note: OGV support (.ogv file extension) depends on the theora module being enabled at compile time (default behavior). Theora compression is only available in editor binaries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddWriter

func AddWriter(writer Instance)

Adds a writer to be usable by the engine. The supported file extensions can be set by overriding HandlesFile.

Note: AddWriter must be called early enough in the engine initialization to work, as movie writing is designed to start at the same time as the rest of the engine.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsMovieWriter() Instance
}

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this [Extension]See Interface for methods that can be overridden by T.

func (*Extension[T]) AsMovieWriter

func (self *Extension[T]) AsMovieWriter() Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Implementation

type Implementation = implementation

Implementation implements Interface with empty methods.

type Instance

type Instance [1]gdclass.MovieWriter

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AsMovieWriter

func (self Instance) AsMovieWriter() Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) ID

func (self Instance) ID() ID

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

type Interface

type Interface interface {
	// Called when the audio sample rate used for recording the audio is requested by the engine. The value returned must be specified in Hz. Defaults to 48000 Hz if [GetAudioMixRate] is not overridden.
	//
	// [GetAudioMixRate]: https://pkg.go.dev/graphics.gd/classdb/MovieWriter#Interface
	GetAudioMixRate() int
	// Called when the audio speaker mode used for recording the audio is requested by the engine. This can affect the number of output channels in the resulting audio file/stream. Defaults to [Audioserver.SpeakerModeStereo] if [GetAudioSpeakerMode] is not overridden.
	//
	// [GetAudioSpeakerMode]: https://pkg.go.dev/graphics.gd/classdb/MovieWriter#Interface
	GetAudioSpeakerMode() AudioServer.SpeakerMode
	// Called when the engine determines whether this [MovieWriter] is able to handle the file at 'path'. Must return true if this [MovieWriter] is able to handle the given file path, false otherwise. Typically, [HandlesFile] is overridden as follows to allow the user to record a file at any path with a given file extension:
	//
	//
	//
	// func _handles_file(path):
	//
	// 	# Allows specifying an output file with a `.mkv` file extension (case-insensitive),
	//
	// 	# either in the Project Settings or with the `--write-movie <path>` command line argument.
	//
	// 	return path.get_extension().to_lower() == "mkv"
	//
	//
	//
	// [HandlesFile]: https://pkg.go.dev/graphics.gd/classdb/MovieWriter#Interface
	// [MovieWriter]: https://pkg.go.dev/graphics.gd/classdb/MovieWriter
	HandlesFile(path string) bool
	// Called once before the engine starts writing video and audio data. 'movie_size' is the width and height of the video to save. 'fps' is the number of frames per second specified in the project settings or using the --fixed-fps <fps> [command line argument].
	//
	// [command line argument]: https://docs.godotengine.org/tutorials/editor/command_line_tutorial.html
	WriteBegin(movie_size Vector2i.XY, fps int, base_path string) error
	// Called at the end of every rendered frame. The 'frame_image' and 'audio_frame_block' function arguments should be written to.
	WriteFrame(frame_image Image.Instance, audio_frame_block gdextension.Pointer) error
	// Called when the engine finishes writing. This occurs when the engine quits by pressing the window manager's close button, or when [SceneTree.Quit] is called.
	//
	// Note: Pressing Ctrl + C on the terminal running the editor/project does not result in [WriteEnd] being called.
	//
	// [SceneTree.Quit]: https://pkg.go.dev/graphics.gd/classdb/SceneTree#Instance.Quit
	// [WriteEnd]: https://pkg.go.dev/graphics.gd/classdb/MovieWriter#Interface
	WriteEnd()
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL