Not able to run cv2.VideoCapture()

I have a dataset containing several videos in .mp4 format stored in a source directory. I want to resize the frames of every video and store in destination directory. I am running a for loop to get every video from source and extract each frame, resize and write in a video and store in destination. But I'm stuck at the VideoCapture part. As far as my knowledge the path is correctly given. Here is the code and the error

 `import cv2
import numpy as np
import os

source="C:\\Users\\Desktop\\sourcedir"
dest=r"C:\Users\Desktop\dest"

def frame_capture(file):

    path=dest+'\\'+file
    so=source+'\\'+file
    
    result = cv2.VideoWriter(path, cv2.VideoWriter_fourcc(*'mp4v'), 25, (227,227))
    
    cap = cv2.VideoCapture(so)

    if(cap.isOpened()==False):
        print("Unable to open file")
        
    currentFrame = 0
    while(True):
          # Capture frame by frame
        ret, frame = cap.read()
        
            # resize frame
        frame=cv2.resize(frame,(227,227))
        result.write(frame)

              # To stop duplicate images
        currentFrame += 1

    cap.release()
    cv2.destroyAllWindows()
        

for file in os.listdir(source):
        frame_capture(file)
    `

OpenCV(4.6.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\resize.cpp:4052: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize

Need help

🔴 No definitive solution yet