godotengine / godot

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

Movie Maker: VideoStreamPlayer doesn't match FPS due to `--fixed-fps` being enabled #69965

Open jorgerosa opened 1 year ago

jorgerosa commented 1 year ago

Bugsquad note: This issue has been confirmed several times already. No need to confirm it further.


Godot version

v4.0.beta8.official [45cac42c0]

System information

Windows 10

Issue description

Using internal GODOT 4 - Beta 8 - "Movie Writer" everything records very well (in my own limited tests), except when recording a scene that has a mesh (it is the plane mesh, named "Ecra" as shown in the image) that gets its texture from a SubViewPort that has a VideoStreamPlayer inside. In the final recorded AVI file, we can notice that the speed is different (it is too fast, seems to me, that is 2x or 3x faster) Note: In the exported "exe" file or when in Godot Editor, the video file plays in the correct speed. No issues.

Recorded with these settings: Recorded with 60 Fps V-Sync is disabled

1) The NODES:

GODOT_4_Beta_8_MovieMaker_1

2) The recorded VIDEO: In this video, uploaded in Youtube, the issue is visible at playing time: 04:53 Note: I haven´t noticed that when recorded it. Everything seems to be fine while recording. Note: Even that its a "vintage" video file that is not its real speed, its 2x or 3x (at least) slower. https://www.youtube.com/watch?v=N0Jr2ig0u8M&list=PLnhzSMPecj1HXo5IGrNFYiGyy6fHZYPTL&index=1

THANKYOU for share with us all your hard work, GODOT team !!!

.

Calinou commented 1 year ago

VideoStreamPlayer doesn't take Engine.time_scale into account, and this is likely a similar case here (as --fixed-fps influences game speed depending on FPS).

@jorgerosa Please upload a minimal reproduction project to make this easier to troubleshoot.

jorgerosa commented 1 year ago

Minimal project: CINEMA.zip Added a minimal project, however Movie Writer seems to be working fine in this one ... I am lost now ...

cyberpsyche commented 1 year ago

As VideoStreamPlayer doesn't take Engine.time_scale into account, my question is how to solve this problem?

Do I have to modify the VideoStreamPlayer to let the video stream's FPS fit with Engine's time_scale ? Is there any other solutions to this issue ?

Calinou commented 1 year ago

As VideoStreamPlayer doesn't take Engine.time_scale into account, my question is how to solve this problem?

Do I have to modify the VideoStreamPlayer to let the video stream's FPS fit with Engine's time_scale ? Is there any other solutions to this issue ?

Unfortunately, I don't see a way to work around this issue. VideoStreamPlayer has to handle a lot of things differently to other nodes because it needs to keep audio and video in sync (among other things). Video playback is hard.

olivergs commented 3 months ago

Just came here to confirm this issue. I've stumbled upon this in a simple UI menu that uses a video as background using Godot 4.2.1.

akx commented 1 month ago

VideoStreamPlayer has to handle a lot of things differently to other nodes because it needs to keep audio and video in sync (among other things). Video playback is hard.

As a concession/workaround, maybe we could have a mode for VideoStreamPlayer where it can ignore any audio in the source video, just so it's able to play the video frames with exact timing. (I suppose this would/could unlock arbitrary video seeking/retiming too...)

olivergs commented 1 month ago

In my specific case that would work perfectly. I use the videoplayer for complex effects on top of a background, so they do not have audio.

akx commented 1 month ago

@olivergs Yep, same here. I ended up only looking at the video as a preview in Godot and doing the postprocessing in ffmpeg. Luckily in my case I could just use an add blend from the Godot output with my background:

ffmpeg -i d24amv_v1_bg.mov -i godot-generated.avi -filter_complex "[0]format=gbrp[bg];[1]format=gbrp[fg];[fg][bg]blend=all_mode='addition':all_opacity=1[final];[final]format=yuv420p" output.mp4