Ensure all MovieWriter frames have the same resolution as the first frame

This fixes issues with certain video formats (like OGV) and video players
not supporting resolution changes during playback.

Resizing the viewport during recording is still not recommended
(as cropping and resizing has a performance cost and can impact visuals),
but it shouldn't cause crashes or broken files anymore.
This commit is contained in:
Hugo Locurcio 2025-07-24 23:53:17 +02:00
parent 5d9722e832
commit 4409c786ca
3 changed files with 53 additions and 15 deletions

View file

@ -4704,7 +4704,21 @@ int Main::start() {
}
if (movie_writer) {
movie_writer->begin(DisplayServer::get_singleton()->window_get_size(), fixed_fps, Engine::get_singleton()->get_write_movie_path());
Size2i movie_size = Size2i(GLOBAL_GET("display/window/size/viewport_width"), GLOBAL_GET("display/window/size/viewport_height"));
String stretch_mode = GLOBAL_GET("display/window/stretch/mode");
if (stretch_mode != "viewport") {
// `canvas_items` and `disabled` modes use the window size override instead,
// which allows for higher resolution recording with 2D elements designed for a lower resolution.
const int window_width_override = GLOBAL_GET("display/window/size/window_width_override");
if (window_width_override > 0) {
movie_size.width = window_width_override;
}
const int window_height_override = GLOBAL_GET("display/window/size/window_height_override");
if (window_height_override > 0) {
movie_size.height = window_height_override;
}
}
movie_writer->begin(movie_size, fixed_fps, Engine::get_singleton()->get_write_movie_path());
}
GDExtensionManager::get_singleton()->startup();