How to get the variable frame rate for a stream?

I am streaming a camera that has a frame rate which is not constant. I am writing a custom logic to calculate my frame and packet losses for that stream but the issue is that the frame rate for the stream it is fetching is constant. Ideally it should fetch the frame rate at the instant at which I am checking it, as some packets, frames might have been lost due to any reason. So how to calculate/get the variable frame rate for a stream?