godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.14k stars 94 forks source link

VideoPlayer node reverse video #3150

Open sanyi12 opened 3 years ago

sanyi12 commented 3 years ago

Describe the project you are working on

Not relevant

Describe the problem or limitation you are having in your project

I need to make a forward video and a reverse video.

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

Just a check box or function with play video in reverse.

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

No idea how reverse videos work.

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

The workaround is to make another video in reverse, when put in the game folder will increase space.

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

It's just a quality of life little checkbox that may be implemented fairly easily.

AaronRecord commented 3 years ago

See also https://github.com/godotengine/godot-proposals/issues/920 (if negative speeds were allowed)

Calinou commented 11 months ago

Unfortunately, this is fundamentally impossible to do in a performant manner because of the way video playback works with formats that use inter-frame compression.

Video formats don't store full frames every frame – instead, they store deltas between the previous frame and the current frame. To allow for fast seeking, keyframes with full frame information are created every 5-10 seconds. This means that for instance, if you want to seek at a precise point in time in a 60 FPS video that has a keyframe every 5 seconds (300 frames), you may need to decode up to 299 frames in a worst-case scenario. Now, imagine having to do this on every frame because you're playing the video in the opposite order that it was encoded to play in. (You can simulate this by holding down the "previous frame" key in a video player – it will be much slower than holding down the "next frame" key.)

Using only intra-frame compression is an alternative (like AVI + MJPEG), but it will make your video file much larger (easily by a factor of 10×). The workaround you mentioned will remain the most optimized way to achieve reverse video playback in the foreseeable future – even if it represents a 2× size increase.

AThousandShips commented 11 months ago

Indeed, the simple solution is to use external software to encode your video in reverse, then you will get the compression as well as reverse

As this is extremely specific (most people won't need this) I'd say this is a sufficient workaround