I have an application where I'm looping a pair of short movies -- one a heavily-processed version of the other, so they're exactly the same length. I'm trying to keep them exactly synchronized (although being perhaps one frame, maybe two, off would be Ok). Right now, they're about a minute long.
If I start them at the same time and let them loop independently, they drift apart over time. Not a *huge* surprise, although it would've been nice if they'd stayed in sync. I added code to rewind them both whenever one finished, and this every-loop reset eliminates extremes in drift, but it's still not unusual to see 10 or so frames of offset at the end of the 1800 or so frames (and it's very wrong, visually).
I'm using movieEvent callbacks to load frames (check to see which movie caused the callback, load the appropriate image). I'm happy to use another method if it'd work better.
I tried a couple of brute-force ways to keep things aligned (like checking the frame numbers and seeking to one or the other if things drift), but performance suffers. Things get much, much worse if I run at anything other that 1X speed (in either direction, fast or slow....somehow, in this conditions, the two movies can get to be seconds off, even within the short minute duration).
Is there a good way to keep a pair of streamed movies synchronized? Should I be using the available() method for figuring out when to read a new frame? Right now, I read each frame and then copy a portion of each to visible. The two video streams are juxtaposed, so this drift is really problematic.
Suggestions? I guess I could read all 1800 frames of each stream into memory, but that seems pretty brutish (and I'm probably most interested in an approach that will work in a more general (unlimited length) case.