opencv frame count

asked 2015-07-29 02:11:28 -0600

w00606 gravatar image

updated 2015-07-29 02:49:29 -0600

fr_cnt = cap.get(CV_CAP_PROP_POS_FRAMES);

I'm getting frame number of a video with this code,

and when it gets a certain key, it skips 50 frames

fr_cnt += 50;
cap.set(CV_CAP_PROP_POS_FRAMES, fr_cnt-1);

but when the frame is skipped, the number of frame shown on the video is counted slower than the real frame number, and the difference gets bigger as the time goes. What would be the problem here?

edit retag flag offensive close merge delete

Comments

I am probably not the only one, but your problem is very unclear to me, especially because the most essential part - how you wrote the key handling - is not showing up in your question. Please edit it and improve the quality...

StevenPuttemans gravatar imageStevenPuttemans ( 2015-07-29 02:49:18 -0600 )edit
1

why the fr_cnt-1 ? (you're obviously only skipping 49 frames, not 50)

berak gravatar imageberak ( 2015-07-29 03:30:31 -0600 )edit
1

I don't understand well your question but consider that setting frame number isn't immediate. It depends of codec used in your video file. When skipping some frames VideoCapture would require to grab/decode all/some frame in the range and this take time.

pklab gravatar imagepklab ( 2015-07-30 12:35:51 -0600 )edit