Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Play a video file with the right timing

Hi,

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 videocapture.read().

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

if (m_fps * elapsedTime < 0.9) return false;

m_videoCapture.read(m_imageBGR);

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); m_videoCapture.read(m_imageBGR)

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

Pellaeon