Seeking frame sync solutions #496
-
I am currently in the process of updating pyxy3d to calibrate and triangulate with pre-recorded footage. My internal target for having that available is end-of-November. One obstacle to the usefulness of this is that it requires input footage start and stop on the same frame, something that I have found is a challenging problem to automate when using footage captured from cameras such as GoPros/iPhones. I'm hoping to better understand what tools currently exist that enable this kind of footage synchronization. I would like to have something to point people toward/use myself/contribute to. @rgov : I'm tagging you here as you had just expressed an interest in this and I'm wondering what your plans for footage sync may be. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 8 replies
-
Other software I've seen just lets you step frame by frame to line up something like a clapper board and then record the offset for each camera. You can show a precise reference clock on an iPhone, say -- those screens get up to 120Hz. If you have audio tracks, you can match up the waveforms and compute the offset, like this project does. I think I saw another project for this but don't remember the name. I experimented earlier this year with using a strobing light and then searching for a pattern in the luma values, but that's for future exploration. |
Beta Was this translation helpful? Give feedback.
-
Documenting here another possible solution to the frame sync: |
Beta Was this translation helpful? Give feedback.
-
I ran an experiment filming with two non-synchronized cameras, of approximately the same model. Stepping through the first few minutes, I found them to have an approximately 30 frame offset, so I padded one video with 30 frames of black to bring them into alignment. However, after an hour of footage the frames were again noticeably out of alignment by about 53 frames. After two hours they are out of alignment by 24 frames. Therefore alignment of the videos seems less straightforward than finding an offset. |
Beta Was this translation helpful? Give feedback.
-
Drift is definitely something that I have been concerned about. My thought has been to enforce synchronization for both the start and stop frames, so there might need to be something like a sound cue at the beginning and end. With those known, estimated times for each frame capture can be assigned. Without the same frame counts, there will be a time misalignment and then during processing the synchronizer will drop time-mismatched frames (EDIT: it won't actually drop frames, it will just insert a blank frame within a batch of synchronized frames). This won't be perfect, but I suspect that this will average out to keep things closely in sync in the presence of drift. The synchronizer is already coded up because dropped frames were a real problem when pulling from multiple webcams at once, so that part of the workflow is already baked in. |
Beta Was this translation helpful? Give feedback.
-
I started to explore synchronization with gopros and smartphone using sound as well, and ran into the same issue as @rgov . The drift between gopro cameras seems to be inconsistent, and I've tracked one possible reason down to the length of time between chunks of videos. It took about 0.05s to save a video, but would not be consistent across different gopros. This leads to sudden dips or increases in the time offset of different videos. I've started exploring syncing the chunks to each other directly, which may improve the syncing within gopros or from gopros to a long smartphone recording, which shouldn't have these sudden jumps. I calculated the drift between smartphone and gopros across time and it seems to be linearly decrease, in which case maybe some linear correction for frame numbers could work. Here are some figures showing the shift in temporal offset calculated every 30 seconds in an hour long video. |
Beta Was this translation helpful? Give feedback.
-
In animal labs, people mostly use Basler / FLIR cameras and set up an external trigger from the same cable, so that the cameras are guaranteed to be synced and recording at a constant framerate. You could use Bonsai or something like https://github.com/ksseverson57/campy to record from those cameras. If you have funding and your setup allows for wiring a common external trigger to each camera, I think this would be the safest option. |
Beta Was this translation helpful? Give feedback.
Ah sorry, I should have provided more details here. The videos are first synced within 0.2 seconds of each other, then I chunk each video in 30 second chunks and estimate the offset by cross-correlating the audio. This is fine in chunks, but I guess at the hour level it fails due to drift.
Yes, that's what I mean about the GoPro chunks. It splits long videos into separate files and there is a pause between saving them. To be honest, I'm not entirely sure if this is the cause, or if the GoPro clock is just messed up somehow?
Here is the code I used to make this:
https://gist.github.com/lambdaloop/e2c50f9bfbadcae8407d9c1a89b9052b