Consider to build a model with Keras Layers where you can stack all the layers like this:
model = Sequential()
model.add(TimeDistributed(Conv2D...))
model.add(TimeDistributed(MaxPooling2D...))
model.add(TimeDistributed(Flatten()))
model.add(TimeDistributed(LSTM, return_sequences=False...)) #or True, in case of Stacked
model.add(TimeDistributed(Dense...))
And try to preprocess videos directly with OpenCV, like read a number of frames from each video and store them into a big tensor that you can split with sklearn train_test_split, like this:
video_folder = '/path.../'
X_data = []
y_data = []
list_of_videos = os.listdir(vide_folder)
for i in list_of_videos:
vid = str(video_folder + i) #path to each video from list1 = os.listdir(path)
cap = cv2.VideoCapture(vid)
frames = []
for j in range(40): #here we get 40 frames, for example
ret, frame = cap.read()
if ret == True:
print('Class 1 - Success!')
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) #converting to gray
frame = cv2.resize(frame,(30,30),interpolation=cv2.INTER_AREA)
frames.append(frame)
else:
print('Error!')
X_data.append(frames) #appending each tensor of 40 frames resized for 30x30
y_data.append(1) #appending a class label to the set of 40 frames
X_data = np.array(X_data)
y_data = np.array(y_data) #ready to split! :)
I hope this help you! :)