Here is a small dummy example using multiple video folders.
Note that I’ve used tensors directly, so you should add your frame loading logic into the Dataset.
class MyDataset(Dataset):
    def __init__(self, videos, transform=None, nb_frames=3):
        self.nb_frames = nb_frames
        self.transform = transform
        
        # Crop data to multiple of nb_frames
        self.data = [v[:-(len(v)%self.nb_frames)] if len(v)%self.nb_frames!=0 else v 
                     for v in videos]
        
        # calculate lengths
        self.lens = [len(d)//self.nb_frames for d in self.data]
        # calculate offsets
        self.offsets = np.concatenate(([0], np.cumsum(self.lens[:-1])))
        
    
    def __getitem__(self, index):
        # subtract offset
        print('index: {}'.format(index))
        # get corresponding video file
        found = False
        for i, offset in enumerate(self.offsets):
            if index < offset:
                print('subtracting {} from index'.format(self.offsets[i-1]))
                index -= self.offsets[i-1]
                index *= self.nb_frames
                found = True
                break
        # handle last video separately
        if not found:
            index -= self.offsets[-1]
            index *= self.nb_frames
            i += 1

        # select correspondind data
        print('selecing video {}'.format(i-1))
        data = self.data[i-1]
        # get frames
        print('reading frames {}'.format([idx for idx in range(index, index+self.nb_frames)]))
        x = []
        for idx in range(index, index+self.nb_frames):
            tmp = data[idx]
            if self.transform:
                tmp = self.transform(tmp)
            x.append(tmp)
        x = torch.cat(x)
        
        return x
        
    def __len__(self):
        return np.sum(self.lens)


videos = [torch.ones(torch.randint(3, 12, (1,)), 1)*i for i in range(5)]

dataset = MyDataset(videos)
for data in dataset:
    print(data)

loader = DataLoader(
    dataset,
    batch_size=2,
    shuffle=True)
for data in loader:
    print(data)

The code currently uses nb_frames consecutive frames for each video folder and removes the trailing frames.
Shuffling using a DataLoader will work.
I’ve also tried to add some debug print statement for better understanding, but let me know, if your need more information about this code.