PyScripts
A collection of Python scripts for video processing and data analysis tasks
PyScripts
A collection of Python scripts for video processing and data analysis tasks. This project provides simple GUI tools for common video operations and data analysis utilities.
Features
- Video Clipping: Extract specific segments from MP4 videos with a user-friendly GUI
- Video Compression: Reduce video file sizes while maintaining quality
- Format Conversion: Convert MKV files to MP4 format using FFmpeg
- Processing Date Estimator: Analyze historical data to estimate when processing dates will reach a target
Prerequisites
- Python 3.11 or higher
- FFmpeg (for video compression and format conversion)
- uv (for dependency management)
Installing FFmpeg
macOS:
brew install ffmpeg
Ubuntu/Debian:
sudo apt update
sudo apt install ffmpeg
Windows: Download from FFmpeg official website or use Chocolatey:
choco install ffmpeg
Installation
-
Clone the repository:
git clone https://github.com/vramdhanie/pyscripts.git cd pyscripts
-
Install uv (if not already installed):
curl -LsSf https://astral.sh/uv/install.sh | sh
-
Install dependencies and create virtual environment:
uv sync
Usage
Video Clipper (clip_mp4.py
)
Extract a specific segment from an MP4 video file.
uv run python pyscripts/clip_mp4.py
Features:
- Select input video file
- Specify start and end times in seconds
- Choose output location
- Preview video duration
Video Compressor (reduce_mp4.py
)
Compress MP4 videos to reduce file size while maintaining quality.
uv run python pyscripts/reduce_mp4.py
Features:
- Set target file size in MB
- Adjust CRF (Constant Rate Factor) for quality control
- Automatic bitrate calculation
- Progress feedback
MKV to MP4 Converter (mkv_to_mp4.py
)
Convert MKV files to MP4 format using FFmpeg.
uv run python pyscripts/mkv_to_mp4.py
Features:
- Fast conversion without re-encoding video
- Audio conversion to AAC format
- Simple file selection interface
Processing Date Estimator (estimator.py
)
Analyze historical processing date data to estimate when a specific eligibility date will be reached.
uv run python pyscripts/estimator.py
Features:
- Linear regression analysis of processing trends
- Interactive matplotlib visualizations
- Automatic date parsing and conversion
- Projection lines for future estimates
- Visual markers for target dates
- Reads data from
data/processing_data.json
Project Structure
pyscripts/
āāā pyscripts/
ā āāā __init__.py
ā āāā clip_mp4.py # Video clipping tool
ā āāā reduce_mp4.py # Video compression tool
ā āāā mkv_to_mp4.py # MKV to MP4 converter
ā āāā estimator.py # Processing date estimator
āāā data/
ā āāā processing_data.json # Input data for estimator
āāā tests/
āāā pyproject.toml # Project configuration
āāā uv.lock # Dependency lock file
āāā README.md
Dependencies
- moviepy: Video editing and processing
- pandas: Data manipulation and analysis
- matplotlib: Data visualization and plotting
- numpy: Numerical computations
- tkinter: GUI framework (included with Python)
- subprocess: System command execution (standard library)
Development
Running Tests
uv run pytest
Code Formatting
uv run black pyscripts/
uv run ruff check pyscripts/
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- MoviePy for video processing capabilities
- FFmpeg for video conversion and compression
- uv for fast Python package management