nguyenquyhy / Flight-Recorder

Record and replay flights in Microsoft Flight Simulator
https://flightsim.to/file/8163/flight-recorder
GNU General Public License v3.0
207 stars 21 forks source link

[FEATURE] Add record sampling rate options in order to have a smooth replay #38

Open omarsmak opened 3 years ago

omarsmak commented 3 years ago

If you currently play a record, sometimes you will notice the replay is bit jittery replay, even if you are having 40-60 fps with no stutters. I guess this is down to the record sampling rate or recording interval? If yes, would be nice to add an option to let the user choose the desired sampling rate in order to have a smoother replay, an example:

example

nguyenquyhy commented 3 years ago

Right now, recording sync to "sim frame", which is the simulation calculation rate and can be different from your graphical FPS, and replaying is synced to your FPS. Since frame timing during recording and replaying is always different, the tools does some interpolation calculation to give the estimated value at replay frame, so basically the recording rate is completely decoupled from the replay rate.

In other words, both recording and replaying adapt to current rate of your computer and wasn't targeting any fixed frequency. I don't know if it is the best way to do, but it looks really smooth for many. I do see jitter in my previous experiments but MSFS on my computer is not jitter-free, so I'm not too sure if the problem is from my calculation or from my specs 😂.

Since your computer is jitter-free, are you able to record any video so I can look more into this? Attaching the .flightrecorder file of the same file would help greatly too.

Besides, I quite dislike adding options/settings, especially for optimization stuffs. Those shouldn't be bothered by users. I might add this to allow more experimentation, but it would be extremely hidden, probably in some setting files.

omarsmak commented 3 years ago

So basically, let's say, the recording happened at sim fps of 20, now I restarted the sim and let's say my sim has recovered its fps and shoot it to 40 (this happened often with MSFS 😅), so now if I play the replay, it will play the record that was sampled at 20fps with 40fps, let's see without the jitters? Sure I can make a video and attach flight recorder file, perhaps it is reproduceable if you try to limit your FPS externally during the record and remove the limit during the replay , that would be an interesting experiment indeed 😅. What happened is that, when I recorded the replay, my sim was stuttering a bit on approach (MSFS typical stuff after long flight), when I play the replay after restarting the sim, I do notice these jitters although after restarting the sim, the fps recovered itself and hence I thought it maybe something related to a fix sampling rate .. etc. But to be fair, the jitters are not so obvious and it is surprising minimal and perhaps which I could think of, perhaps it needs maybe minimal tweaks to reach the desired smoothness.

nguyenquyhy commented 3 years ago

So basically, let's say, the recording happened at sim fps of 20, now I restarted the sim and let's say my sim has recovered its fps and shoot it to 40 (this happened often with MSFS 😅), so now if I play the replay, it will play the record that was sampled at 20fps with 40fps, let's see without the jitters?

Yep. It does basic linear interpolation at replay to produce frame data at 40fps to the sim. Linear might not be very accurate, but even at 20fps, we are looking at movement during 50ms, so I guess the difference wouldn't really be visible.

What happened is that, when I recorded the replay, my sim was stuttering a bit on approach (MSFS typical stuff after long flight), when I play the replay after restarting the sim, I do notice these jitters although after restarting the sim, the fps recovered itself and hence I thought it maybe something related to a fix sampling rate .. etc.

I might be wrong, but it's more likely that during recording, the data is already messed up due to the stuttering (e.g. SimConnect returns the same data for 2 consecutive frames). This would result in the exact same stuttering during replay regardless of the rates.

If you do have any .flightrecorder files with consistent stuttering at a particular point in time, it would help a lot. I have some scripts that do pre-calculation & drawing charts and stuffs to track this down. But I don't really have consistent data for this. All of my stuttering is just too random.

omarsmak commented 3 years ago

Here it the flight recorder file and a video. Now looking at the video again, I really can't tell if the jitter is from the sim itself or from the replay (looking at the main thread utilization), however I think the jitter is not so obvious as I thought it will be. Nevertheless, you can take a look at the video and the file, perhaps you can find anything wrong or we can just close the ticket as I can't really tell from my side :).

Video: https://streamable.com/9m5bju

Flight recorder file: 2021-02-28-19-16.zip

Edit: Look from 1:08 onward, you will a notice a weird jitter, that what I noticed sometimes although not always.

Drangoll commented 3 years ago

Having the same Issue with stutters. Setting max framerate (vsync at 30 fps) during recording helped a lot but there are still some stutters at touchdown Here's my replay file