The ethoscope stores periodic JPEG snapshots of the camera frame in the SQLite database (table IMG_SNAPSHOTS). The script video_from_ethoscope_db.py extracts these snapshots and compiles them into a standard MP4 video, with optional overlay of tracked fly positions.
accessories/databases/video_from_ethoscope_db.py
opencv-python, numpy, tqdmffmpeg with libx264 encoderTo create a simple timelapse video from the snapshots stored in a .db file:
python video_from_ethoscope_db.py /path/to/database.db
This will produce an .mp4 file in the same directory as the input database, with each frame annotated with its timestamp.
Use the --track (or -t) flag to overlay the tracked fly coordinates on each frame. The script cross-references the ROI_* tracking tables with the snapshot timestamps, finding the nearest tracked position for each fly and drawing it as an ellipse:
python video_from_ethoscope_db.py /path/to/database.db --track
The ellipses match the style used in the live tracking view:
METADATA table to retrieve the experiment start timeIMG_SNAPSHOTS with their timestamps