-
-
Notifications
You must be signed in to change notification settings - Fork 22k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement a Movie Maker mode #62122
Implement a Movie Maker mode #62122
Conversation
Closes godotengine/godot-proposals#3083? |
@YuriSizov yeah, thanks! Let me amend this. |
See also #60660, which implements the same feature (but probably with some differences). |
write_movie_path = I->next()->get(); | ||
N = I->next()->next(); | ||
if (fixed_fps == -1) { | ||
fixed_fps = 60; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if implicitly falling back to 60 FPS is a good idea. I would at least print a message in this case to warn the user that no fixed FPS was specified on the command line, and that the default value of 60 will be used instead.
Something like:
No `--fixed-fps <fps>` argument specified on the command line. Will be recording video at 60 FPS (non-realtime).
See also #60284, which adds a project setting to set fixed FPS (and also allows toggling it at run-time). It would be interesting to make the movie writer toggleable at run-time, but it sounds difficult to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only really for running from command line because it needs something. The actual writer has a project setting option and it always passed the proper fixed fps value.
unsigned int buffer_frames; | ||
unsigned int mix_rate; | ||
SpeakerMode speaker_mode; | ||
uint32_t buffer_frames = 4096; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the number of buffer frames be adjustable with a project setting? This seems like a high value to default to – most other games I've seen default to 1024.
That said, for offline recording, we can probably perform latency compensation so it sounds like audio has zero latency, even if a high number of buffer frames is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unrelated to latency, it just needs it to to save audio temporarily.
I'd probably name the feature tag |
Would it be possible to add support for image sequences (or more specifically, a folder usually full of .png files) to avoid compression loss due to jpeg encoding. My understanding is image sequences such as png are fairly common, and Godot already supports png compression so it seems like an easy |
AVI does not support lossless compression, although it does support saving uncompressed data (resulting in huge files). I'd look at the quality loss when using JPEG quality 100 first, as it may be barely noticeable in most scenarios (especially at higher input resolutions). A PNG image sequence will therefore be smaller than a lossless AVI file, but it'll also take much longer to save as PNG encoding is notoriously slow compared to JPEG. The tradeoff is sometimes worth it, but it'll impact your rendering speed a lot unless PNG saving is moved to its own thread (or better, its own multithread pool). For this to work, Godot would have to save a PNG image sequence and a WAV file containing the audio besides it. The naming of PNG files should be friendly to tools like FFmpeg to allow converting it to a video easily, but it should be able to handle dozens of thousands of frames if needed. |
Does this support exporting alpha channel? Or does it have the ability to output the alpha channel as a separate file? (Or can it be easily added later?) In the use case of software like FaceRig or Live2D, when exporting video, alpha support is a very powerful tool for compositing purposes. |
} else if (I->get() == "--disable-vsync") { | ||
disable_vsync = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See also godotengine/godot-proposals#1923. I think the way this PR currently handles V-Sync disabling is fine – it's just something to keep in mind for the future.
Either way, I'll definitely appreciate having this CLI argument available for games that don't expose a way to turn off V-Sync, so kudos for adding it 🙂
It's also useful to disable V-Sync on the editor without affecting the running project (at least until #48364 is merged).
JPEG doesn't support saving an alpha channel, and neither does uncompressed AVI to my knowledge. A PNG image sequence would be the only way to achieve this without having to generate a separate AVI that contains just the alpha channel. (If you need this, you can probably do it by running Godot twice with different options that make it display the alpha channel only using a shader.) |
When using shaders to split the export in two, there is a possibility that transparent objects will be affected by the color of the background. For similar reasons, pre-multiplied alpha and chroma key is generally not preferred in the video compositing process, and straight alpha is preferred. Also, perfect reproducibility is required for physics, user input, random seed and other operations. For these reasons, I believe it makes more sense to render those at the same time. I think it is fine to have alpha channel support at the same time as the png sequence implementation, but it would be preferable if this PR is an implementation that can easily integrate that. For example, it should not ignore the fact that the background is transparent prior to file encode process; just as the background |
@lyuma @TokageItLab PNGs are enormous I tested and saved videos are like 10 times bigger. Additionally they are very slow to encode and annoying to handle if you re-run movie export because you need to delete the old ones. As transparency or lossless video is quite a very corner case, I think it will be better if you make a small extension reimplementing MovieWriter yourself to save in the way you prefer. It really is super easy to do it. |
336ded2
to
9ff5748
Compare
9ff5748
to
6e3b7b5
Compare
I tend to disagree - at least for lossless. If you want to alter anything after the recording, you will want to have a lossless video to not lose even more detail. Creating my own implementation of |
6e3b7b5
to
1a338d2
Compare
Thanks! |
I was asking this on reddit, but it's probably better to ask here:
Hm, I'm still not sure I understand. What I would expect from this play mode is guaranteed rendering at a certain frame rate. So if I set it to 60 fps, I would expect the resulting avi file would contain exactly 60 frames every second, rendered gameplay at regular 0.016 intervals. But I would not expect this mode to have 60 fps while playing/recording: If one frame for example would take 0.5 seconds to render while the other frames only take 0.016 seconds, I would expect to see this one frame for 0.5 seconds on screen while playing/recording in this mode, but during playback of the video file, I would not see any hickup, just smooth 60fps and no pauses in gameplay. This means, provided the playing/recording framerate is stable because my hardware can handle it, it should be totally fine record gameplay with it. Even recommendable and advantageous over FRAPS or OBS who will also records any frame rate dips. Even if my hardware can't cope and I therefore get freezing frames while playing/recording in this mode. If these dips are within the millisecond spectrum, and Inputs don't change radically, I don't see any negative consequence recording gameplay. The recorded video should almost always look better (while of course playing with hickup ain't as much fun). But when you are recording video footage of your project, you having fun with gameplay while doing so is not the top most priority anyway. You are creating assets to reuse in your project or for marketing. Am I wrong here? Did I miss something obvious? Recording interactive project footage would be my main use of this thing. If this is not what this does, why would you want to have this? Blender is a thousand times more suitable for linear movie 3D rendering and production, any Animation Software for 2D animation and rendering. |
@golddotasksquestions Your description is accurate. What reduz is saying above is that this isn't useful for streaming your game online or equivalent. |
Is it possible to use this feature from a compiled game? |
Yes, the code isn't compiled out of non-editor builds and the command line argument is still available in exported projects (even in release mode). However, this functionality cannot be toggled while the project is running. Therefore, you'll need to call Godot supports running multiple instances of the same project at once, so this should work out fine. |
It's good you have impleneted .AVI, but will there also be .OGV and .MP4? |
Given the discussion above, that's not going up happen, but you can convert to any container and codec you like using ffmpeg. Or if you're adventurous and need the ability to export mp4 in your app, you can write a plugin with the codec, or a plugin that wraps ffmpeg. Ffmpeg is open source. |
There's more context in the proposal on why this was implemented the way it was. Please read the context and existing Q&A in the comments here before asking more questions :) There's a lot of licensing requirements for using h264 (mp4), and I don't think we currently bundle an ogv/theora encoder meaning it would bloat the binary size which isn't good. |
For those who want to record fixed animations from godot 3 you can use https://github.com/simonknowsstuff/Godot-Film-Maker !! |
Hello, any way to add the alpha channel (png) only for the image sequences? since in addition to being useful for videos it would also be very useful for the creation of 2d isometric renderings like diablo 2, I know that in blender you can create a rotation script and make a screenshot every x time but having it in godot would save time to anyone who wants to use it all without leaving the engine |
As mentioned above, using a transparent viewport won't work as the final window is still opaque. Movie Maker only "sees" the final window, not intermediate viewports. You have two remaining options:
|
You can do that in Godot already, in a similar way you can do it in Blender. Just take screenshots using viewport texture and rotate your model. |
@YuriSizov Hello, I can do that easily, what I wanted was to have a transparent background so that only the rendered 3d model would remain. I have been trying subwiport but the gray background is still saved -_- reference videos so that you understand well what I wanted to explain |
@drcucaracha Yes, I get what you need. Your viewport needs to be set to transparent background, and that information is correctly stored in its texture, but saving it to PNG for some reason renders transparent areas black. I guess you have to follow Calinou's advice then and either generate a texture just for alpha value, or use a keying out technique. |
In the future, you could have a built in ui node that allows the player to record gameplay and even edit it! I understand that compared to other game engines, Godot has limited devs, so I don't expect these features to be implemented now, but sometime in the future, maybe for Godot 5, yow'l could try it! |
Could you please add a back port this important feature to 3.X version? As this is a relative independent feature and many 3.X apps will want to use this feature to output game video, but upgrading all the 3.X will take a long time, for many apps they will always been in 3.X stage. Thanks a lot! |
While this feature is technically possible to backport, this won't be tackled by core contributors as they're focusing on getting 4.0 in a releasable state. The visual capabilities of Godot 3.x are also more limited, making a Movie Maker mode less interesting to have there. That said, anyone is free to try 🙂
Remember that Movie Maker mode is not designed to be used by players to record video. It's a tool for project developers first and foremost, e.g. for creating game trailers. |
Resolves godotengine/godot-proposals#3083.
What is it?
This new features has two main use cases, which have high demand:
Note: This feature IS NOT for capturing real-time footage. Use something like OBS, SimpleScreenRecorder or FRAPS to achieve that, as they do a much better job at intercepting the compositor than Godot can probably do using Vulkan or OpenGL natively. If your game runs near real-time when capturing, you can still use this feature (but it will lack audible sound playback, as sound is saved directly to the video file).
Usage:
User Interace:
Enable the Movie Maker mode by toggling the new icon on the run panel:




Then set up the recording parameters in the project settings, including the output file:
For running standalone scenes, it is possible to specify custom move files for each by adding a "movie_file" metadata to the root node:
Command line:
$ godot --write-movie movie.avi [scene_file.tscn]
Missing:
Options for configuring video writing via GLOBAL_DEFUI Menu for launching with this mode from the editor.Add to list of command line options.Add a feature tag to override configurations when movie writing (fantastic for saving videos with highest quality settings).Known Limitations: