Advice on dataset/dataloader for videos

Hello great minds,

I need some advice about my dataset/dataloader. Any comments are welcomed!

I have 100 videos.
Every video has around 300 frames.
Every video has its own json file including frame number, info1 and info2.

I would like the dataset/dataloader:

for each video:

  1. Take n frames(adjacent) (eg. frames[0,n], frames[1,n+1], …, frames[end-n, end])
  2. Check if each of the n frames meet info1 and info2 request, if yes, take this n frames as one sample(input) , if no, ignore it and try with next n frames.

Continues with other 99 videos.

When loading the dataset, I could either

  1. Load two samples from the same video
  2. Load two samples from different videos
  3. Just load one sample

It is a mess in my brain about how to arrange the code. Please offer me some advice. Thank you in advance!!!