1

In our implementation, we need know the pts or frame-number of the frame decoded with OpenCV, and then after doing some process based on the decoded frame, and then build a map between the pts or frame-number in the original stream and the process result.

After checking the OpenCV VideoCapture I/F, I didn't find this kind of method.

ravin.wang
  • 1,122
  • 1
  • 9
  • 26

1 Answers1

1

The OpenCV video interface does not expose many details about the video stream. It is intended to be a high-level interface for easy frame grabbing, it does not give access to low-level information of the codecs.

The frames returned by VideoCapture::read are just images, they don't contain any information about the video (likea a frame number). You need to keep that information manually, separately.

If you start decoding at the beginning of the file, you can just use an integer counter for the successfully decoded frames that are returned from VideoCapture::read.

Then there is VideoCapture::get, with which you can access CV_CAP_PROP_POS_MSEC, CV_CAP_PROP_POS_FRAMES and CV_CAP_PROP_FPS, which is as close you can get to PTS with the OpenCV interface.

w-m
  • 10,772
  • 1
  • 42
  • 49
  • Thanks, it can be got from this way, but in some IPCameras I tried, the value got from CV_CAP_PROP_POS_MSEC and CV_CAP_PROP_FPS are the crazy values, for example, 180fps, but my IPCamera does not support this frame-rate. – ravin.wang Aug 22 '18 at 10:20