This guide will help you extract frames from a video using Docker and a simple Python script. Follow the steps below to get started.
- Docker: Ensure Docker is installed on your machine. You can download and install Docker from here.
- Git: Ensure Git is installed on your machine. You can download and install Git from here.
Open a terminal (or command prompt) and run the following command to clone the repository:
git clone https://github.com/VittuD/custom_frame_extractor.gitThis will create a directory named custom_frame_extractor.
Navigate to the custom_frame_extractor directory:
cd custom_frame_extractorEnsure your directory structure looks like this:
custom_frame_extractor/
├── Dockerfile
├── requirements.txt
├── extract_frames.py
├── run_extraction.sh
├── input_videos/
└── output_frames/
└── ...
- input_videos: This folder will contain the videos you want to process.
- output_frames: This folder will store the extracted frames.
Copy the video file you want to process into the input_videos folder. For example, if your video file is named example.mp4, place it inside the input_videos directory.
Open a terminal (or command prompt) and ensure you are in the custom_frame_extractor directory. Then, run the extraction script with the name of your video file.
sh run_extraction.sh example.mp4Replace example.mp4 with the name of your video file.
After the script completes, you will find the extracted frames inside the output_frames folder. The frames will be stored in a subfolder named after your video file (without the extension).
For example:
output_frames/
└── example/
├── frame0000.jpg
├── frame0001.jpg
├── frame0002.jpg
└── ...
If there are updates to the repository, follow these steps to ensure you have the latest version of the scripts and other files.
-
Navigate to the Local Repository:
- Open a terminal and navigate to the local repository directory.
cd path_to_your_local_repository
- Open a terminal and navigate to the local repository directory.
-
Pull the Latest Changes:
- Fetch and merge the latest changes from the remote repository.
git pull origin main
- Fetch and merge the latest changes from the remote repository.
-
Pull the Latest Docker Image (if necessary):
- If there were changes to the
Dockerfileor other dependencies, pull the new Docker image.docker pull davidevitturini/frame-extractor
- If there were changes to the
- Docker Not Installed: Ensure Docker is installed and running on your machine.
- File Not Found: Make sure the video file name is correct and placed in the
input_videosfolder. - Permissions: You might need to run the terminal or command prompt with administrative privileges.
- Cannot Execute 'run_extraction.sh': Make sure the
run_extraction.shscript has execute permissions. You can set this by running:
chmod +x run_extraction.shIf you encounter any issues or have questions, please reach out to my institutional email or refer to the Docker documentation for troubleshooting tips.