godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.08k stars 20.19k forks source link

Movie writer doesn't use correct aspect ratio with window override and stretch settings #71254

Open joemicmc opened 1 year ago

joemicmc commented 1 year ago

Godot version

4.0 beta 10

System information

Windows 10, Vulkan, AMD RX 5600 XT

Issue description

When you set a combination of settings in project settings > general > display > window, the output avi file does not have the correct aspect ratio

Size

Stretch

Steps to reproduce

Minimal reproduction project

movie-writer-aspect-ratio.zip

joemicmc commented 1 year ago

Current workaround is to not use the window override and then scale the avi using extra ffmpeg arguments (use it already to convert to mp4). Nearest neighbour is to try and preserve the crisp pixels.

ffmpeg -i input.avi -s WIDTHxHEIGHT -sws_flags neighbor output.mp4

Calinou commented 1 year ago

This is strange, because only the viewport dimensions should matter when using the viewport stretch mode in Movie Maker mode. The actual window size set with the override should not affect the dimensions of the output video, even if you resize it while recording. This is why I was originally able to document https://github.com/godotengine/godot-docs/pull/6398.

That said, even if this is fixed, the video will still not be scaled for you – you'll have to do this in post-process, or use a custom viewport instead of relying on the root viewport's scaling.

joemicmc commented 1 year ago

Hehe, I just updated my script to convert avi to mp4 to do the scaling! So have a workaround.

Also, used the cool project settings overrides to set the window overrides in movie mode to be 0 so I don't have to keep changing settings. Such a neat feature.

Ayush-singla27 commented 1 year ago

if i understood this correctly, the main issue is that output avi file should not scale with actual window size. Right?

Calinou commented 1 year ago

if i understood this correctly, the main issue is that output avi file should not scale with actual window size. Right?

It should when using the disabled or 2d stretch modes, but not when using the viewport stretch mode.

skeddles commented 2 months ago

I ran into this too, still happening in 4.2.2

setting stretch mode to disabled and resetting window_width_override/window_height_override to 0 is sort of a workaround, if you want to render at 1x

though I found it better to change stretch mode to canvas_items, then you can keep the width/height override and render at a higher resolution, which is what I was hoping for / expecting. i would still have expected it to render scaled up with the viewport mode set to stretch.

imo rendering at 1x and then scaling up with nearest neighbor is a bad idea because the frames are getting jpeggified (even if mjpeg quality is set to 1 apparently), and you're going to end up scaling up that jpeggification making it much more noticeable.

Calinou commented 2 months ago

imo rendering at 1x and then scaling up with nearest neighbor is a bad idea because the frames are getting jpeggified (even if mjpeg quality is set to 1 apparently), and you're going to end up scaling up that jpeggification making it much more noticeable.

For pixel art, you should use PNG output (or QOI if https://github.com/godotengine/godot/pull/91263 is merged). JPEG is still a lossy format at 100% quality.

skeddles commented 2 months ago

My target destination is still video, even with rendering it to PNG, it would still end up getting JPEGged at the end when converted to MP4 - I'm just suggesting people avoid scaling up JPEG/JPEGged video because it will scale up the artifacts and make them more noticeable.

Though it's true, rendering to PNG could be a better workaround for now, if you want to force everything to be rendered at the native resolution, since changing to the canvas_items stretch mode renders everything at higher res.

But I hope this can be fixed so that when using the viewport stretch mode you can render scaled up pixel art video at the native resolution.