Skip to content
Advertisement

How do I run my Python OpenCV code on all video files in a folder?

I have written some python code for extracting two frames from a video file using OpenCV. I have tested my code and it works for one video file.

However, I have a folder with hundreds of video files and I would like to extract two frames from all the videos in that folder. Is there a method of doing this for all the files in a folder? Perhaps using the os module or something similar?

My code is below for reference:

JavaScript

Advertisement

Answer

Just make it function ad call it in a for loop for every video

JavaScript

for the loop:

JavaScript
Advertisement