Batching image data based on timestamp contained in filename

I have a dataset of images in keras-style:


I create a dataset object by calling


Then i unbatch it either by applying or x,y:

I need to batch this data in windows of “n” temporally-consecutive elements (for ease, let’s say 3 elements, although the exact number isn’t decided yet). The images come from a set of videos, so i want batches of 3 images, each image 1 second apart. If there’s more than 1 second between at least 2 consecutive frames in the window, i want to drop that whole window
I’ve been trying to figure out how to do it, and have tried a number of approaches, but i have been unable to do what i need
I tried:
use the API and use the .window() method. This creates the dataset of windows, but resulting dataset loses the .file_paths property, meaning there is no way for me to check whether the elements in a window belong together or not
use the .map() function, didn’t manage to make it work with the dataset i have

I have also converted my dataset to TFRecord format, using this script, but i don’t really understand how to load the data and batch it

any help is greatly appreciated