public static float FindNextKeyFrameTimeSeconds(float seconds, float frameRate, int keyFrameInterval) { int currentFrame = Helper.ConvertTimeSecondsToFrame(seconds, frameRate); // TODO: allow specifying a minimum number of frames so that if currentFrame is too close to nextKeyFrame, it will calculate the next-next keyframe int nextKeyFrame = keyFrameInterval * Mathf.CeilToInt((float)(currentFrame + 1) / (float)keyFrameInterval); return(Helper.ConvertFrameToTimeSeconds(nextKeyFrame, frameRate)); }
/// <inheritdoc/> public int GetDurationFrames(float overrideFrameRate = 0f) { int result = 0; float frameRate = (overrideFrameRate > 0f)?overrideFrameRate:GetVideoFrameRate(); if (frameRate > 0f) { result = Helper.ConvertTimeSecondsToFrame(GetDuration(), frameRate); } return(result); }
/// <inheritdoc/> public int GetCurrentTimeFrames(float overrideFrameRate = 0f) { int result = 0; float frameRate = (overrideFrameRate > 0f)?overrideFrameRate:GetVideoFrameRate(); if (frameRate > 0f) { result = Helper.ConvertTimeSecondsToFrame(GetCurrentTime(), frameRate); result = Mathf.Min(result, GetMaxFrameNumber()); } return(result); }
/// <inheritdoc/> public void SeekToFrameRelative(int frameOffset, float overrideFrameRate = 0f) { float frameRate = (overrideFrameRate > 0f)?overrideFrameRate:GetVideoFrameRate(); if (frameRate > 0f) { int frame = Helper.ConvertTimeSecondsToFrame(GetCurrentTime(), frameRate); frame += frameOffset; frame = Mathf.Clamp(frame, 0, GetMaxFrameNumber(frameRate)); double time = Helper.ConvertFrameToTimeSeconds(frame, frameRate); Seek(time); } }