Skip to content

TX-220/mediac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mediac — Directory-based Image & Video Batch Compressor

High-compression batch tool for images and videos running on local WSL2/Ubuntu. Automatically backs up originals, never overwrites without confirmation.

Images: PNG, JPG, WebP, GIF, BMP, TIFF → WebP (high compression)
Videos: MP4, MOV, AVI, MKV, WMV, FLV, WebM → MP4/H.265 (HEVC) (high compression)


Quick Start

Prerequisites

  • WSL2 or Ubuntu Linux
  • Python 3.11+
  • ffmpeg (with libx265)

Install System Dependencies

sudo apt update
sudo apt install -y ffmpeg

Verify ffmpeg has H.265 support:

ffmpeg -encoders 2>/dev/null | grep hevc

Install mediac

pip install -e ".[dev]"

Usage

CLI: Compress with Backup (Recommended)

mediac compress ./media --level medium --backup ./.compress_backup

CLI: Estimate Reduction (Dry-Run, No Changes)

mediac dry-run ./media --level medium

CLI: Restore from Backup

mediac rollback --manifest ./media/.mediac/manifest.db

Web UI (Local)

mediac gui
# Opens at http://127.0.0.1:8765
  • Scan: Shows file counts and estimated reduction
  • Compress: Real-time progress, displays savings
  • Rollback: One-click restore from backup

Compression Levels

Level Image Quality Video CRF Use Case
low 88 23 High quality, larger files
medium 78 28 Balanced (default)
high 65 32 Aggressive, smaller files

Key Features

✅ Safe by Default

  • Automatic backup before any compression
  • Atomic replace — original + backup always consistent
  • Verification — output checked before replacing
  • Rollback support — restore originals anytime

⚡ Parallel Processing

  • Images: Multi-core CPU parallel (ProcessPool)
  • Videos: Single thread per file (H.265 = CPU-heavy)
  • Configurable concurrency

📊 Reporting

  • Final report (text + JSON) with counts & savings
  • Per-file logs in .mediac/logs/
  • Manifest DB for re-run skip detection

Important Notes

Default: Backup is ON

By default, originals are moved to ./.compress_backup/. If compression fails or you want originals back:

mediac rollback --manifest ./media/.mediac/manifest.db

Disable Backup (⚠️ Destructive)

mediac compress ./media --no-backup

WARNING: Without --backup, originals are permanently deleted if compression fails.

Re-compress Already Compressed Files

mediac compress ./media --force

By default, files already compressed are skipped.


Known Limitations

WSL2 H.265 Encoding

  • WSL2 uses CPU-only encoding (no hardware acceleration)
  • Large videos (>1GB) may take 10+ minutes
  • Consider splitting very large files first

Single Files

mediac works on directories only, not individual files.


Output Structure

media/
├── photo.webp          (compressed; original in backup)
├── video.mp4           (compressed HEVC)
└── .mediac/
    ├── manifest.db     (state DB for resume/rollback)
    ├── logs/           (per-run logs)
    └── tmp/            (temp files during compression)

.compress_backup/
├── photo.png           (original backup)
└── (directory structure preserved)

Troubleshooting

ffmpeg/ffprobe Not Found

# Install
sudo apt install -y ffmpeg

# Verify
ffmpeg -version
ffprobe -version

Out of Disk Space

mediac checks before starting and reserves 2GB margin. Free up space and retry.

Permission Denied on Backup Directory

chmod -R u+w .compress_backup/

Video Compression Very Slow

Normal on WSL2 (CPU-only). Check Task Manager — x265 should be using ~100% CPU.


Architecture

  • scanner.py — Recursively find images/videos by magic bytes (filetype)
  • image_compressor.py — Pillow + WebP via ProcessPool
  • video_compressor.py — ffmpeg + libx265 via ThreadPool
  • dispatcher.py — Parallel job scheduler with graceful exit
  • pipeline.py — Orchestrate scan → compress → verify → swap
  • manifest.py — SQLite state DB (resume, skip, rollback)
  • webapp.py — FastAPI Web UI + SSE progress streaming
  • cli.py — typer CLI entrypoint

License

MIT License — Copyright (c) 2026 TX-220

See LICENSE for details.


Credits

TX-220 — Concept, design, direction
Claude (Anthropic) — Implementation
Claude Code & Claude Desktop — Development tooling


Contributing

Bug reports and pull requests welcome at GitHub.


FAQ

Q: Does mediac delete originals?
A: No — by default, originals are moved to .compress_backup/. Use --no-backup only if you want them deleted; this disables automatic rollback.

Q: Can I interrupt compression?
A: Yes. Files already completed are recorded in .mediac/manifest.db and skipped on re-run.

Q: What formats does mediac support?
A: Images: PNG, JPG, GIF, BMP, TIFF, WebP → WebP
Videos: MP4, MOV, AVI, MKV, WMV, FLV, WebM → H.265/MP4

Q: Is there a Docker / container version?
A: Not currently — WSL2/Ubuntu native only.

About

Directory-based image & video batch compressor (CLI + local Web UI)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors