Table of Contents

Class MovieWriter

Namespace
Godot
Assembly
GodotSharp.dll

Godot can record videos with non-real-time simulation. Like the --fixed-fpscommand line argument, this forces the reported delta in _Process(double) 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 2 built-in MovieWriters:

- 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/mjpeg_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.

public class MovieWriter : GodotObject, IDisposable
Inheritance
MovieWriter
Implements
Inherited Members

Constructors

MovieWriter()

public MovieWriter()

Methods

AddWriter(MovieWriter)

Adds a writer to be usable by the engine. The supported file extensions can be set by overriding _HandlesFile(string).

Note: AddWriter(MovieWriter) 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.

public static void AddWriter(MovieWriter writer)

Parameters

writer MovieWriter

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

_GetAudioMixRate()

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.

public virtual uint _GetAudioMixRate()

Returns

uint

_GetAudioSpeakerMode()

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 ModeStereo if _GetAudioSpeakerMode() is not overridden.

public virtual AudioServer.SpeakerMode _GetAudioSpeakerMode()

Returns

AudioServer.SpeakerMode

_HandlesFile(string)

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(string) 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"
public virtual bool _HandlesFile(string path)

Parameters

path string

Returns

bool

_WriteBegin(Vector2I, uint, string)

Called once before the engine starts writing video and audio data. movieSize 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.

public virtual Error _WriteBegin(Vector2I movieSize, uint fps, string basePath)

Parameters

movieSize Vector2I
fps uint
basePath string

Returns

Error

_WriteEnd()

Called when the engine finishes writing. This occurs when the engine quits by pressing the window manager's close button, or when Quit(int) is called.

Note: Pressing Ctrl + C on the terminal running the editor/project does not result in _WriteEnd() being called.

public virtual void _WriteEnd()