Record timestamps from multiple cameras and microphones

428 views
Skip to first unread message

Alessandro La Chioma

unread,
Feb 14, 2021, 11:45:04 AM2/14/21
to Bonsai Users
Hello
I am a new user of Bonsai and my first impression is quite positive!

I would like to simultaneously record data from multiple cameras and microphones, with timestamps of each source all according to the same timebase. With cameras this is simple. I got something to work for the microphone, but I'm not sure what I did is reliable...

In the workflow attached below for example, the timestamp for audio should be every 10 msec (timing dictated by the buffer length), but it jitters quite a bit (+/-5 ms). By increasing buffer length it gets better, but I'm not sure what side effects this might have.

screenshot_test_2cameras_1mic.png

Any feedback would be appreciated, thanks!

Alessandro

Gonçalo Lopes

unread,
Mar 14, 2021, 4:00:56 PM3/14/21
to Alessandro La Chioma, Bonsai Users
Hi Alessandro and welcome to the forums,

I guess this would all depend on what timebase you want to use for your synchronization and how precise you need the synchronization to be. If you would like to pair up audio and video buffers together in real-time, an easy way to do it while avoiding drift is to use the WithLatestFrom operator with your fastest source as the main input:

image.png

This will pair up the latest frame of video every time a new audio buffer arrives. The output will be at 100Hz (~10ms interval). If this is too fast for your video stream, what you can do is then use Slice with the Step property > 1 (e.g. Step=2 for 50Hz, Step=3 for 30Hz, Step=4 for 25Hz, etc).

You can combine it with more video sources by using CombineLatest on all the cameras and send the output to WithLatestFrom.

This will give you a structured format where all the audio samples will be written to file and there is a fixed relationship between audio buffer time and video time which will not drift over time. There will still be a small jitter in the video which may or may not be negligible depending on your video frame rate and timing needs.

Hope this helps.



--
You received this message because you are subscribed to the Google Groups "Bonsai Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bonsai-users/6c9a5c3e-bfb2-4c58-8e1c-d541f98f3772n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages