1
$\begingroup$

I am getting a bit confused about fps (frame rate) in a video.

I build a video (using python and opencv) using 600 frames and I specify 10 fps.

However I want to also record the timestamps for each frame in a text file. If the time for the first frame is 0 ns what would be the time stamp for the second frame provided the values I gave above?

EDIT:

About my confusion. If we have 10 frames with 0.1 difference we have

|     |   |    |    |    |    |    |    |    |
-------------------------------------------------------------
0   0.1  0.2  0.3  0.4  0.5  0.6  0.7  0.8  0.9

As you can see the time for the 10 frames is not one second but less so fps would not be 10 fps

|      |     |     |    |     |     |    |     |    |
-------------------------------------------------------------
0   0.11  0.22  0.33  0.44  0.56  0.67  0.78  0.89  1

Wouldn't this be the correct calculation?

$\endgroup$
3
  • $\begingroup$ Given the frame-rate FPS, then the duration between the frames is: $\Delta T = 1/FPS$ and the n-th frame is at time $t_n = (n-1)*\Delta T$, where $n = 1,2,...,N$ having $N = 600$ total frames $\endgroup$
    – Fat32
    Commented May 10, 2022 at 11:49
  • $\begingroup$ I get very confused by this. Shouldn't it be 1/(FPS-1)? Because if not the N frames will have a difference less than FPS $\endgroup$ Commented May 11, 2022 at 7:37
  • $\begingroup$ For your convenience, if you have 10 frames at 10 FPS, then the 10th frame will be at: $t_{10} = (n-1) \times \Delta T = (10-1) \times (1/10) = 0.9 $ s, where $\Delta T = 1/FPS = 1/10 = 0.1 s$.. And if there would be any 11th frame, it would be at 1.0 s... So if there are N frames in the interval [ 0 , T ] s , then your frame rate is FPS = (N-1)/T . (your first figure is correct) $\endgroup$
    – Fat32
    Commented May 11, 2022 at 11:07

1 Answer 1

1
$\begingroup$

Python implementation:

import numpy as np

frames = 600
# frames per seconds
fps = 10 
# sampling time in seconds
t_s = np.arange(600) / fps
# sampling time in nano-seconds
t_ns = t_s * (10**9)

Regarding the confusion related to the duration, the problem is that the sampling does not start at $t=0$, where the first sample takes place. If you consider that the sampling starts at $t=-\frac{1}{F_s}$ then it would all make sense.

Please do not neglect the integration time, which is part of the sampling process. For example, in the attached figure the sampling starts at $t=0$ but the first sample is at $t=\frac{1}{F_s}$. enter image description here

$\endgroup$
2
  • $\begingroup$ that 600 should be frames right? (in t_s calculation) $\endgroup$ Commented May 11, 2022 at 6:55
  • $\begingroup$ I run this script. My only doubt is that if I substact t_ns[599] from t_ns[0] it gives me 59900000000.0 which divided by 10**9 gives me 59.9. Shouldn't it be 60? $\endgroup$ Commented May 11, 2022 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.