godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

Implement support for writing AVI files larger than 4 GB in Movie Maker mode #4752

Open Calinou opened 2 years ago

Calinou commented 2 years ago

Related to https://github.com/godotengine/godot-proposals/issues/4751.

Describe the project you are working on

The Godot editor :slightly_smiling_face:

Describe the problem or limitation you are having in your project

Godot now has offline video recording functionality, but its AVI writer is limited to files of 4 GB in size. This is problematic for recording long movies, or even shorter movies at high quality (such as 4K @ 60 FPS).

You can work around this by using a PNG image sequence, but it's much slower to encode, especially at high resolutions. You could also record several shorter videos and stitch them in a video editing program, but this isn't very convenient, especially when audio is involved.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Implement support for writing AVI files larger than 4 GB in Movie Maker mode.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Quoting https://github.com/godotengine/godot/pull/62122:

AVI has extensions to overcome this limitation (basically saving multiple RIFF chunks) but they are not implemented yet. It can be done later if someone feels inspired.

If this enhancement will not be used often, can it be worked around with a few lines of script?

No.

Is there a reason why this should be core and not an add-on in the asset library?

This is about improving built-in Movie Maker functionality to make it more usable for long-form video production.

TokisanGames commented 2 years ago

AVI has extensions to overcome this limitation (basically saving multiple RIFF chunks) but they are not implemented yet. It can be done later if someone feels inspired.

Some players or editors may not support >4gb AVI files. Alternatively, the writer could just make a sequence of AVIs, #0001-9999 once the limit is reached. This is how some older cameras worked to support continuous recording.

Then the documentation could include some ffmpeg commands to concatenate the files without reencoding, and convert them to superior containers. Mov supports mjpeg >4gb. https://trac.ffmpeg.org/wiki/Concatenate

And instructions to concatenate and convert to other codecs. But make it clear this is lossy and the above is not.

Or you could just drop AVI support and replace it with MOV.

fire commented 2 years ago

How much difficulty is it to support mkv?

Calinou commented 2 years ago

How much difficult is it to support mkv?

MKV is a much complex specification than AVI (or even MOV), so it's probably out of scope for core. Even MOV is significantly more complex than AVI already.

drsounds commented 1 year ago

The video files created by Godot is near useless, they are treated as corrupted by most video software, VLC and the original version of Virtual Dub is the only software which can play the file, but they can't export it.

Calinou commented 1 year ago

The video files created by Godot is near useless, they are treated as corrupted by most video software, VLC and the original version of Virtual Dub is the only software which can play the file, but they can't export it.

As described in the documentation, you need to exit Godot using get_tree().quit() or AnimationPlayer's Movie Quit On Finish for the AVI files to be properly terminated. Terminating the Godot process (including with the X button in the window title bar) won't do this. It should be feasible to implement a SIGTERM signal handler to handle this gracefully, but it's not trivial.

It might be possible to use an external tool to "repair" incomplete AVI files and properly terminate them, but I haven't looked. In my experience, there are video players which can play those incomplete AVIs properly, such as mpv.