Klaus Schmidinger wrote:
Detecting the frame rate is done by looking at the PTS values, so it is independent of the actual broadcast system.
Using this code for converting frame numbers into hh:mm:ss.ff...
#include <math.h> #include <stdio.h>
int main(void) { double FramesPerSecond = double(90000) / 3003; //FramesPerSecond = 25; for (int Index = 0; Index < 10000; Index++) { double Seconds; int f = round(modf(Index / FramesPerSecond, &Seconds) * FramesPerSecond) + 1; int s = int(Seconds); int m = s / 60 % 60; int h = s / 3600; s %= 60; printf("%3d ", Index); printf("%15.9f ", Index / FramesPerSecond); printf("%d:%02d:%02d.%02d", h, m, s, f); if (f > 30) printf(" *"); printf("\n"); } }
... sometimes results in a 31st frame:
9978 332.932600000 0:05:32.29 9979 332.965966667 0:05:32.30 9980 332.999333333 0:05:32.31 * 9981 333.032700000 0:05:33.02 9982 333.066066667 0:05:33.03
Any ideas how to fix this?
eg
- int f = round(modf(Index / FramesPerSecond, &Seconds) * FramesPerSecond) + 1; + int f = round(modf(Index / FramesPerSecond, &Seconds) * FramesPerSecond + 0.5 );
note that some 'seconds' will contain only 29 frames. (see index 510 in the original and 1019 in the fixed version)
artur