Reading Videos through PyTorch DataLoader

I am facing issue in Pytorch DataLoader.
I created a custom video data-loader in pytorch but the issue arises that every time I am trying to read a video file, the code doesn’t show any error but it doesn’t read any data regarding the viedo read like its frames, NumFrames etc. (No problem in reading video file names)

But Whenever I try to read the video files with same code snippet (without Pytorch DataLoader), it runs smoothly as per the need

Could you please help here?

in __getitem__() function ::

 vid_file    = self.csv_vid_metadata["FileName"][item]            
            vis_data    = cv2.VideoCapture(vid_file)
            numFrames   = int(vis_data.get(cv2.CAP_PROP_FRAME_COUNT))
            frameWidth  = int(vis_data.get(cv2.CAP_PROP_FRAME_WIDTH))
            frameHeight = int(vis_data.get(cv2.CAP_PROP_FRAME_HEIGHT))
            frame_buffer= np.zeros((numFrames, frameHeight, frameWidth, 3), np.dtype('uint8'))

            print("vid_file, numFrames, frameWidth, frameHeight:::::",vid_file, numFrames, frameWidth, frameHeight)