logo
Vincent Ramdhanie
Senior Software Engineer

PyScripts

A collection of Python scripts for video processing and data analysis tasks

šŸ“… January 2024šŸ’» Python00
PythonFFmpegMoviePyPandasMatplotlibTkinterPoetryuv
pythonvideo-processingdata-analysisguiffmpegautomation

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

  1. Clone the repository:

    git clone https://github.com/vramdhanie/pyscripts.git
    cd pyscripts
    
  2. Install uv (if not already installed):

    curl -LsSf https://astral.sh/uv/install.sh | sh
    
  3. 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

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. 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