friction2d / friction

Friction Graphics
https://friction.graphics
GNU General Public License v3.0
312 stars 16 forks source link

Issue with video speed being affected by scene framerate #322

Open KirbysDarkNebula opened 3 weeks ago

KirbysDarkNebula commented 3 weeks ago

As the title describes, videos get sped up or slowed down to accommodate for scene framerate: If the scene framerate is 60fps and a given video is 30fps the video will play at 2x speed (ONLY the video, the audio maintains its speed) Likewise if a video is 60fps and the scene framerate is 30fps the video will play at 0.5x speed, while the audio remains normal

Weirdly enough this discordance between audio and video remains when applying time stretching, if you try to "undo" the effects of 2x speed by slowing the video down by 50% (setting stretch to 200) then the video goes back to normal as expected but the audio also gets slowed down to by 50%.

(Edit: I'm using version 1.0.0-beta1)

KirbysDarkNebula commented 1 week ago

After checking some more I realised the problem is the way the program handles scene framerates and video framerates. There is no transcoding or adjusting of any kind for video, it just sets the video frames to timeline frames, so if a video has 30 frames in 1 second, after importing into a 30fps scene it'll be mapped 1:1, but if you import that same video into a 60fps scene it will STILL be mapped 1:1, making the video play faster than it should.

example 600 frames scene @ 30fps, 20 seconds of duration We add a 10 seconds long video @ 30fps, the video plays normally, each video frame is mapped to a scene frame, 1:1 600 frames scene @ 60fps, 10 seconds of duration We add a 10 seconds long video @ 30fps, the video plays twice as fast, each video frame is mapped to a scene frame 1:1, instead of maintaining the video frame for 2 scene frames.

I'm currently looking through the code to see where exactly this takes place.

KirbysDarkNebula commented 1 week ago

Found it, I'll try to submit a fix that takes scene framerate into account when calculating the video framerate later!

rodlie commented 1 week ago

That would be awesome :+1: