fanadventures.net

Header
English
 
Forum overview > Calculate the correct frame delay (or the speed) of an animation
  • Calculate the correct frame delay (or the speed) of an animation

    by Lebostein · Thursday, 10. December 2015, 11:03 h ~ 4 years ago
    I have generated (with AnimeStudio) an animation with n = 300 frames related to fps = 24. If I export these animation to a movie, the lenght of the movie is t = n / fps = 12.5 seconds.

    To get the display lenght p of one frame, I have to calculate p = t * 1000 / n = 41.6666 ms. Or the easier way to calculate this is p = 1000 / fps = 41.6666 ms.

    If I import the single frames to Visionaire and use 40 ms for the pause value, then the animation ist to slow. It runs more than 15 seconds. How I calulate the correct pause value? What means "pause" in Visionaire?
    Lebostein
  • by Lebostein · Thursday, 10. December 2015, 11:27 h ~ 4 years ago
    This pause value is more problematic than I thought:

    pause = 42 ms -> 15 sec animation lenght
    pause = 36 ms -> 15 sec animation lenght
    pause = 34 ms -> 15 sec animation lenght
    ----> it seems around 33 ms is a hard "jump"
    pause = 32 ms -> 10 sec animation lenght
    pause = 26 ms -> 10 sec animation lenght

    It seems the frame pause value generates only wide graded results. In my case it is impossible to get an animation length of 12.5 seconds. It seems there are other influences (internal main loop delays, vertical sync delays....) which controls the animation speed. Perhaps someone can explain it.
    Lebostein
  • by afrlme · Thursday, 10. December 2015, 11:43 h ~ 4 years ago
    The problem is that it's reliant on the system loop of Visionaire Studio which varies slightly with each loop. 60fps for example is approx 1 frame every 16.33 milliseconds (or something like that).

    I tend to just mess around with the pause value until I find something that looks ok.

    You also have to take into account loading times or lag due to loading animations, especially if the animation has loads of frames. The best approach is less frames & adjust the pause (delay) value to simulate smoother animation than it actually is. Think of it as a juggling act.

    P.S: there is no reason at all to try to make your animations as smooth as an animated movie. You can achieve similar results most of the time with a fraction of the amount of animation frames. You also do not need to use duplicated frames to control the speed of the animation as it's possible to set individual pause values for individual frames - if needed.
    afrlme
  • by SimonS · Thursday, 10. December 2015, 11:46 h ~ 4 years ago
    The frame can only be changed when a frame is drawing, this happens at 60fps. So to get 24fps in 60fps you would need to stack the frames something like this: 2 - 3 - 2 - 3 - 2 - 3 ...
    Can you see the resulting stuttering here ?
    What the engine does is change the frame, set the timer and wait until it's over. So the timer has been set and after 40ms the image is changed, this happens in the 3th frame: 16,6 - 33,3 - 49,9 and the timer is reset again, so it will change on these frame counts: 3 - 3 - 3 - 3 - 3 - 3
    When it's lower than 33,3 you get 2 frames per image.

    Conclusion: If you want time perfect animations, use a framerate that can be displayed in frames of 60fps: 30fps, 15fps, 7,5fps: 32ms, 64ms, 128ms
    SimonS
  • by Lebostein · Thursday, 10. December 2015, 12:11 h ~ 4 years ago
    OK, Thanks for the input. I will try something out. In future I will use 15 fps for my animations in combination with 64 ms delay. This is enough for the type of adventure I make.

    PS: But in this case the "pause" value is very confusing for the user. It will give the impression that one could adjust the speed in the millisecond range.
    Lebostein
  • by afrlme · Thursday, 10. December 2015, 12:26 h ~ 4 years ago
    OK, Thanks for the input. I will try something out. In future I will use 15 fps for my animations in combination with 64 ms delay. This is enough for the type of adventure I make.

    PS: But in this case the "pause" value is very confusing for the user. It will give the impression that one could adjust the speed in the millisecond range.


    Well... they can, but you can't go below 15ms (or as Simon says 32ms in this case) because animations may play really fast on certain machines. The pause (delay value between frames) may need to vary depending on each animation & the amount of frames it has & whether or not you use duplicated frames to control the speed of the animation.
    afrlme
  • by Lebostein · Friday, 11. December 2015, 09:35 h ~ 4 years ago
    How I can measure time in lua? os.time() gives full seconds only and os.clock() gives milliseconds but works correct with windows only (because it is the cpu time and not the real time)....
    Lebostein
  • by ke4 · Friday, 11. December 2015, 10:11 h ~ 4 years ago
    AFRLme wrote some functions for that on wiki.

    http://wiki.visionaire-tracker.net/wiki/SecondsToTime_(CMS)
    ke4
  • by Lebostein · Friday, 11. December 2015, 12:35 h ~ 4 years ago
    @Ke4: That is only a format function for time values, not a function to measure time.

    I have used os.time() and measured 10-20 animation cycles for an average value. In the image below are the results for an animation with 200 frames. You can see (from the practical point of view) what SimonS said. The animation speed can not be linear controlled by the "Pause" value. It is only a "rough request". The real animation speed is limited by the framerate or a multiple of the framerate.

    Note: Some "Pause" values are "somewhere in between" (33,34,35 & 49,50,51 & 65,66,67 ...). This "Pause" values produce undefined animations lenghts somewhere in between. I would not recommend these values, because they probably produce different animations lengths on different computers.
    Lebostein
  • by Lebostein · Friday, 11. December 2015, 12:55 h ~ 4 years ago
    Here is the little lua script, that is called on the first frame of my endless looped test animation:

    local old = timer
    timer = os.time() -- or use: os.clock()
    if old ~= 0 then
    local duration = timer - old
    summe = summe + duration
    counter = counter + 1
    print(duration, summe / counter) -- current and average duration
    end

    1
    2
    3
    4
    5
    6
    7
    8

    You have to define the global vars timer = 0, counter = 0 and summe = 0 in a global definition script before!
    Lebostein
  • by afrlme · Friday, 11. December 2015, 13:02 h ~ 4 years ago
    Interesting. Thanks for the chart thing.

    Yes the pause timing is a bit weird but it is dependent on how fast the engine loops, which as you stated might differ on various machines.

    In regards to the time it takes to display the animation, I think most people probably won't even notice if it plays a little fast or slow. The only person that really knows how fast it should play is you or the animator that created said animation. So a couple milliseconds or seconds here & there shouldn't really matter...

    The important thing is getting the timings of interactions right. The best approach for that is by adding action parts directly into the animation frames themselves, that way you can trigger when to change a condition, update a value, start another animation playing, trigger some dialog or whatever.

    I think you will end up losing all your hair (if you haven't already done so) if you spend too much time worrying about things like timing. Sort your game first then worry about it later on. Besides I couldn't really tell you if any other engines would get timings perfectly spot on either. The only things I can think of are gif animations & rendered videos.

    P.S: Try to remember that it's a game & not an animated movie, so things don't have to look ├╝ber smooth.

    P.P.S: I like how you misspelled length on your chart but correct in the text you wrote above the attachment. smile
    afrlme
  • New post