Skip to content
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

Any ways to set clip in slowmotion ? #10

Open
PockPocket opened this issue Aug 7, 2023 · 1 comment
Open

Any ways to set clip in slowmotion ? #10

PockPocket opened this issue Aug 7, 2023 · 1 comment

Comments

@PockPocket
Copy link

Hey,
I'm trying to set one of the Record3D clip from my scene in slow-motion via the timeline but the option is greyed out:

r3d-slow-motion_Debug

Do you have any alternative to set individual .r3d clips in slow-motion ?
Thanks a bunch,
Mathieu

@marek-simonik
Copy link
Owner

Hi Mathieu,

I'm not sure why the two options are grayed-out, but here is the place where loading of frames happens for Timeline-based animation and where you should implement the playback logic you want.

You can adjust the speed of the clip e.g. by introducing a speedUpFactor property like in the example below (you could define a similarly named speedUpFactor property also on Record3DPlayback, which you could access from within R3DVideoBehaviour by calling input.endLocation.speedUpFactor; the speed-up factor property could be manually specified in the scene inspector).

double speedUpFactor = 5.0;
int frameIdx = (int)Math.Round(speedupFactor * playableInput.GetTime() * input.endLocation.fps);

Or instead of using speedUpFactor, you could directly compute the current frame index based on where in the Clip is the animation playhead currently located; the speedup would then be defined by how much you stretch the Clip in the Timeline:

var clipDuration = playableInput.GetDuration(); // Duration of the clip in the Timeline
var currClipTime = playableInput.GetTime(); // The time at which the playhead is located (relative to the start of the Clip)
double percentageOfVideo = currClipTime / (clipDuration == 0.0 ? 1.0 : clipDuration);

int frameIdx = (int)Math.Round(percentageOfVideo * input.endLocation.numberOfFrames);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants