BGE: add audio/video synchronization capability to VideoTexture
Add optional parameter to VideoTexture.Texture refresh() method to specify timestamp (in seconds from start of movie) of the frame to be loaded. This value is passed down to image source and for VideoFFmpeg source, it is used instead of current time to load the frame from the video file. When combined with an audio actuator, it can be used to synchronize the sound and the image: specify the same video file in the sound actuator and use the KX_SoundActuator time attribute as timestamp to refresh: the frame corresponding to the sound will be loaded: GameLogic.video.refresh(True, soundAct.time)
This commit is contained in:
@@ -92,7 +92,7 @@ void ImageRender::setBackground (int red, int green, int blue, int alpha)
|
||||
|
||||
|
||||
// capture image from viewport
|
||||
void ImageRender::calcImage (unsigned int texId)
|
||||
void ImageRender::calcImage (unsigned int texId, double ts)
|
||||
{
|
||||
if (m_rasterizer->GetDrawingMode() != RAS_IRasterizer::KX_TEXTURED || // no need for texture
|
||||
m_camera->GetViewport() || // camera must be inactive
|
||||
@@ -105,7 +105,7 @@ void ImageRender::calcImage (unsigned int texId)
|
||||
// render the scene from the camera
|
||||
Render();
|
||||
// get image from viewport
|
||||
ImageViewport::calcImage(texId);
|
||||
ImageViewport::calcImage(texId, ts);
|
||||
// restore OpenGL state
|
||||
m_canvas->EndFrame();
|
||||
}
|
||||
|
Reference in New Issue
Block a user