π¦ ClawHub
Media Compress
by @1987566643
Compress and convert images and videos using ffmpeg. Use when the user wants to reduce file size, change format, resize, or optimize media files. Handles com...
π‘ Examples
Image Compression
# Compress to target size (auto-adjusts quality)
python scripts/compress_image.py photo.jpg --max-size 200kbResize + compress
python scripts/compress_image.py photo.png --width 800 --output photo_small.jpgConvert to WebP (better compression)
python scripts/compress_image.py photo.jpg --format webpBatch compress entire folder
python scripts/compress_image.py ./photos --output ./compressed --quality 80Preview mode - see what will happen without compressing
python scripts/compress_image.py photo.jpg --max-size 500kb --previewKeep backup of original file
python scripts/compress_image.py photo.jpg --max-size 500kb --backup
Video Compression
# Compress with default settings (good balance)
python scripts/compress_video.py video.mp4 --output video_small.mp4Resize to 720p
python scripts/compress_video.py video.mp4 --height 720Target specific file size (approximate)
python scripts/compress_video.py video.mp4 --target-size 50mbLower quality for smaller file
python scripts/compress_video.py video.mp4 --crf 28Batch process all videos in folder
python scripts/compress_video.py ./videos --output ./compressed --height 480Preview mode - see what will happen without compressing
python scripts/compress_video.py video.mp4 --height 720 --previewKeep backup of original file
python scripts/compress_video.py video.mp4 --height 720 --backup
βοΈ Configuration
ffmpeg must be installed:
sudo apt update && sudo apt install ffmpegbrew install ffmpegVerify installation: ffmpeg -version
π Tips & Best Practices
"ffmpeg not found"
Install ffmpeg first:# Ubuntu/Debian
sudo apt update && sudo apt install ffmpegmacOS
brew install ffmpeg
"Permission denied"
Make scripts executable:chmod +x scripts/*.py
Quality too low
Increase quality setting:# Image
python scripts/compress_image.py photo.jpg --quality 90Video
python scripts/compress_video.py video.mp4 --crf 20
File not smaller
--max-size to force target sizeBatch processing stops
Check that all files in directory are valid images/videos. Corrupt files may cause errors.TERMINAL
clawhub install media-compress