Play a video file with the right timing

asked 2015-01-30 02:05:01 -0500

Pellaeon gravatar image


I use VideoCapture to read an avi file and copy the frames to a video texture within my ogre3d application. I want the video is shown with a right timing (not too slow, not too fast). My first approach was to use the elapsed time, to calculate the passed (fps * elapsedTime [in seconds]) frames and if the passed frame is > 1 do a

auto elapsedTime = m_timer.elapsed().wall / 1000 / 1000.0;

if (m_fps * elapsedTime < 0.9) return false;;

Unfortunately, the video is to slow with this code.

Therefore, I use teh following command to set the video stream to the right position:

m_videoCapture.set(CV_CAP_PROP_POS_MSEC, elapsedTime);

Now my question to this solution: is there a performance drawback. Surely, there is some buffer mechanism in the background so that the read call can grab the next frame effecently? But when I set the position every time, perhaps the buffering is troubled?

Best regards


edit retag flag offensive close merge delete