Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

🗜️ Video-Compress

Smart Temporal & Spatial Video Compression Algorithm using Alternating Checkerboard Reconstruction
Developed by RMNO21

Python 3.8+ OpenCV NumPy Stars License


💡 Overview

Video-Compress is an experimental computer vision and spatial-temporal compression pipeline. Instead of standard lossy quantization, it leverages an alternating checkerboard pixel decimation technique combined with a 4-neighbor Selective Mean Filter to reconstruct high-frequency details with minimal perceptual loss.

🧠 How the Algorithm Works:

  1. Checkerboard Decimation: Each frame is divided into a 2D checkerboard grid of even and odd coordinates.
  2. Temporal Interlacing: Odd and even pixel sub-grids alternate across successive frames at target frame rates (30+ FPS), taking advantage of human visual persistence (temporal blending).
  3. Selective Mean Edge Reconstruction: To eliminate halos and blur around sharp edges, the algorithm analyzes the 4 cardinal neighbors (Up, Down, Left, Right), automatically identifies and discards the highest-variance outlier neighbor, and computes the spatial average of the remaining 3 closest pixels.

✨ Key Features

  • High-Speed Vectorized Processing: Fully vectorized with NumPy matrix rolling and masking operations.
  • 🎯 Edge-Preserving Selective Mean: Eliminates artifacting and ghosting around high-contrast edges.
  • 🔄 Temporal Alternation: Preserves motion fidelity without full-frame data duplication.
  • 📦 Minimal Dependencies: Requires only standard opencv-python and numpy.

🚀 Quick Start

1. Prerequisites & Installation

Clone the repository and install the dependencies:

git clone https://github.com/RMNO21/video-compress.git
cd video-compress
pip install opencv-python numpy

2. Run the Compression Script

python pixel.py

When prompted, enter the full path to your source video file:

Video File Path: "C:\path\to\your\video.mp4"

The script will process each frame with a live progress indicator and save the reconstructed output as processed_pixel_video.mp4 in the same directory.


📊 Pipeline Comparison

Step Technique Visual Effect
Stage 1 Checkerboard Decimation Reduces per-frame pixel payload
Stage 2 4-Neighbor Outlier Rejection Discards boundary noise
Stage 3 Tri-Neighbor Interpolation Reconstructs missing pixel coordinates
Stage 4 Temporal Frame Alternation Leverages persistence of vision

⭐ Support the Project

If you find this computer vision experiment interesting, please consider giving it a Star ⭐!
Contributions, optimizations, and PRs are always welcome.


📜 License

MIT License © RMNO21

About

Smart temporal & spatial video compression script reducing file size up to 50% using FFmpeg

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages