This Python script processes video files by extracting metadata, removing inactive segments, and creating lower resolution versions while maintaining the original aspect ratio. It also supports actor recognition using facial recognition techniques.
- Load actor images and create a JSON file for actor data.
- Extract metadata from videos, including scene changes and actor recognition.
- Remove inactive segments from videos.
- Create lower resolution versions of videos (360p, 480p, 720p, 1080p, 1440p, 4K, and 8K).
- Save screenshots from the video.
- Overwrite existing output files based on modification dates or user flags.
- Python 3.x
- FFmpeg (must be installed and added to system PATH)
- Required Python libraries:
- OpenCV
- face_recognition
- Pillow
- Pillow-Heif
- NumPy
You can install the required libraries using pip:
pip install -r requirements.txt
To run the script, use the following command in your terminal or command prompt:
python video_processor.py <video_dir> <actor_dir> <output_dir> [--refresh] [--overwrite]
<video_dir>
: Directory containing the videos to process.<actor_dir>
: Directory containing actor images (subdirectories for each actor).<output_dir>
: Directory where processed videos and metadata will be saved.--refresh
: (Optional) Force refresh of actor data, reloading images and overwriting the existingactor_data.json
.--overwrite
: (Optional) Overwrite all data in the output directory. If not set, only overwrite files if the input video has a more recent modified date.
python video_processor.py "C:\path\to\video\directory" "C:\path\to\actor\directory" "C:\path\to\output\directory" --refresh --overwrite
The script generates the following outputs in the specified output directory:
- Processed video files with actor names in the filename.
- Lower resolution versions of the videos (if applicable).
- Metadata files containing scene timestamps, actors, descriptions, and titles.
- Screenshots from the video.
- Ensure that the actor images are in supported formats (JPEG, PNG, TIFF, HEIC).
- The script handles various video resolutions, including 4K and 8K, and maintains the aspect ratio when creating lower resolution versions.
- If no actors are detected in a video, the output filename will not include any actor suffix.
- If you encounter errors related to file paths, ensure that you are using the correct syntax for your operating system.
- Make sure FFmpeg is installed and accessible from the command line.
- Check for any missing dependencies and install them as needed.
This project is licensed under the MIT License - see the LICENSE file for details.