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:
@@ -71,7 +71,7 @@ bool ImageBase::release (void)
|
||||
|
||||
|
||||
// get image
|
||||
unsigned int * ImageBase::getImage (unsigned int texId)
|
||||
unsigned int * ImageBase::getImage (unsigned int texId, double ts)
|
||||
{
|
||||
// if image is not available
|
||||
if (!m_avail)
|
||||
@@ -82,12 +82,12 @@ unsigned int * ImageBase::getImage (unsigned int texId)
|
||||
// get images from sources
|
||||
for (ImageSourceList::iterator it = m_sources.begin(); it != m_sources.end(); ++it)
|
||||
// get source image
|
||||
(*it)->getImage();
|
||||
(*it)->getImage(ts);
|
||||
// init image
|
||||
init(m_sources[0]->getSize()[0], m_sources[0]->getSize()[1]);
|
||||
}
|
||||
// calculate new image
|
||||
calcImage(texId);
|
||||
calcImage(texId, ts);
|
||||
}
|
||||
// if image is available, return it, otherwise NULL
|
||||
return m_avail ? m_image : NULL;
|
||||
@@ -305,12 +305,12 @@ void ImageSource::setSource (PyImage * source)
|
||||
|
||||
|
||||
// get image from source
|
||||
unsigned int * ImageSource::getImage (void)
|
||||
unsigned int * ImageSource::getImage (double ts)
|
||||
{
|
||||
// if source is available
|
||||
if (m_source != NULL)
|
||||
// get image from source
|
||||
m_image = m_source->m_image->getImage();
|
||||
m_image = m_source->m_image->getImage(0, ts);
|
||||
// otherwise reset buffer
|
||||
else
|
||||
m_image = NULL;
|
||||
|
Reference in New Issue
Block a user