This project allows users to capture multiple frames from a video file or a YouTube video by providing either a local video path or a YouTube URL. You can either download the video to your system or extract frames directly from an existing video file. Frames are captured at intervals and saved as image files in a specified folder. The code is well-commented for ease of understanding.
- Download videos from YouTube using
yt-dlp. - Process local video files or YouTube videos to capture frames.
- Save frames at regular intervals as images.
- User-friendly prompts for path input and download options.
- Fully commented code for easy learning and adaptation.
- Python: Core programming language.
- OpenCV: Used for reading videos and capturing frames.
- yt-dlp: Used for downloading YouTube videos.
- OS Module: Handles file paths and directories.
- Python 3.x
- Required Python libraries:
opencv-pythonyt-dlp
- Clone the repository:
git clone https://github.com/yourusername/YouTube-Frame-Extractor.git cd YouTube-Frame-Extractor - Install the required dependencies:
pip install opencv-python yt-dlp
-
Run the script:
python your_script_name.py
-
When prompted:
- Enter the path of the local video file or YouTube URL.
- Decide if you want to download the YouTube video or not.
- Specify the path to save the downloaded video (if applicable).
- Choose whether to capture frames from the video.
- Specify the directory where the captured frames will be saved.
-
The program will automatically capture frames every 100 milliseconds from the video and save them as images in the specified directory.
-
Press 'q' to exit the frame capture process early if needed.
Enter path/url to the video: https://www.youtube.com/watch?v=example_video
Do you want to download the YouTube video? (yes/no): yes
Enter the path where you want to download the video (e.g., C:\Users\YourUsername\Downloads): C:\Users\YourUsername\Downloads
Do you want to capture multiple frames of this video? (yes/no): yes
Enter the path where you want to save captured images (e.g., C:\Users\YourUsername\Images): C:\Users\YourUsername\ImagesThe program will download the video, process it, and save the frames as PNG images to your specified directory.
Feel free to contribute by submitting pull requests or reporting issues!