media-compress

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 common formats like JPG, PNG, WebP, MP4, MOV, WebM. Triggers on phrases like "compress image", "compress video", "reduce file size", "convert to webp/mp4", "resize image", "make image smaller", "batch compress", "optimize media".

Safety Notice

This item is sourced from the public archived skills repository. Treat as untrusted until reviewed.

Copy this and send it to your AI assistant to learn

Install skill "media-compress" with this command: npx skills add 1987566643/media-compress

Media Compression Skill

Compress and convert images and videos with intelligent defaults. Supports single files and batch processing.

Supported Formats

Images: JPG, PNG, WebP, BMP, TIFF, GIF → JPG, PNG, WebP Videos: MP4, MOV, AVI, MKV, WebM, FLV, WMV, M4V → MP4

Prerequisites

ffmpeg must be installed:

Verify installation: ffmpeg -version

Quick Start

Image Compression

# Compress to target size (auto-adjusts quality)
python scripts/compress_image.py photo.jpg --max-size 200kb

# Resize + compress
python scripts/compress_image.py photo.png --width 800 --output photo_small.jpg

# Convert to WebP (better compression)
python scripts/compress_image.py photo.jpg --format webp

# Batch compress entire folder
python scripts/compress_image.py ./photos --output ./compressed --quality 80

# Preview mode - see what will happen without compressing
python scripts/compress_image.py photo.jpg --max-size 500kb --preview

# Keep 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.mp4

# Resize to 720p
python scripts/compress_video.py video.mp4 --height 720

# Target specific file size (approximate)
python scripts/compress_video.py video.mp4 --target-size 50mb

# Lower quality for smaller file
python scripts/compress_video.py video.mp4 --crf 28

# Batch process all videos in folder
python scripts/compress_video.py ./videos --output ./compressed --height 480

# Preview mode - see what will happen without compressing
python scripts/compress_video.py video.mp4 --height 720 --preview

# Keep backup of original file
python scripts/compress_video.py video.mp4 --height 720 --backup

Common Use Cases

1. Upload to Website (Image)

Most websites need images under 500KB:

python scripts/compress_image.py photo.jpg --max-size 500kb --format webp

2. Email Attachment (Image)

Email often has 25MB limit:

python scripts/compress_image.py scan.pdf.jpg --max-size 5mb --quality 90

3. Social Media Video

Platforms prefer 720p, smaller files:

python scripts/compress_video.py clip.mov --height 720 --crf 23 --preset fast

4. Archive Old Videos

Maximum compression for storage:

python scripts/compress_video.py old_video.avi --crf 28 --preset slow --height 480

5. Convert Format Only

Keep quality, just change format:

# Image
python scripts/compress_image.py image.png --format jpg --quality 95

# Video
python scripts/compress_video.py video.mov --output video.mp4 --crf 18

Parameters Reference

Image (compress_image.py)

ParameterDescriptionDefault
inputInput file or directory (required)-
--output, -oOutput file or directoryAuto-generated
--max-sizeTarget max file size (e.g., 500kb, 2mb)None
--quality, -qJPEG/WebP quality (1-100)85
--width, -wMax width in pixelsOriginal
--heightMax height in pixelsOriginal
--format, -fOutput format: jpg, png, webpOriginal format
--no-stripKeep metadata (default: remove)False
--preview, -pPreview mode: show settings without compressingFalse
--backup, -bKeep backup of original fileFalse

Video (compress_video.py)

ParameterDescriptionDefault
inputInput file or directory (required)-
--output, -oOutput file or directoryAuto-generated
--crfQuality 0-51 (lower=better). 18=visually lossless, 23=default, 28=smaller23
--presetEncoding speed: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslowmedium
--heightMax height (480, 720, 1080)Original
--target-sizeApproximate target size (e.g., 50mb, 1gb)None
--fpsLimit frame rate (e.g., 30, 24)Original
--audio-bitrateAudio quality (e.g., 128k, 192k)128k
--preview, -pPreview mode: show settings without compressingFalse
--backup, -bKeep backup of original fileFalse

Quality Guidelines

Images

  • 90-95: High quality, minimal compression artifacts
  • 85: Sweet spot (default) - good quality, significant size reduction
  • 70-80: Acceptable for web, smaller files
  • 50-60: Low quality, visible artifacts

Videos (CRF)

  • 17-18: Visually lossless, archival quality
  • 20-22: High quality, professional use
  • 23: Default, good balance (recommended)
  • 28: Smaller files, acceptable quality
  • 35+: Low quality, preview/draft only

Presets

  • ultrafast: Fastest encoding, largest files
  • fast: Quick results, slightly larger
  • medium: Default balance
  • slow: Better compression, smaller files
  • veryslow: Maximum compression, smallest files

Batch Processing

When input is a directory:

  • All supported files are processed
  • Output directory structure mirrors input
  • Progress shown for each file
  • Original and compressed sizes displayed

Example:

$ python scripts/compress_image.py ./vacation_photos --output ./compressed --max-size 500kb
找到 24 个图像文件
[1/24] 处理: IMG_001.jpg
  ✓ 2847.3KB → 456.2KB (84.0% 减少)
[2/24] 处理: IMG_002.png
  ✓ 1532.1KB → 298.5KB (80.5% 减少)
...

Troubleshooting

"ffmpeg not found"

Install ffmpeg first:

# Ubuntu/Debian
sudo apt update && sudo apt install ffmpeg

# macOS
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 90

# Video
python scripts/compress_video.py video.mp4 --crf 20

File not smaller

  • Try lower quality or smaller dimensions
  • Some files are already optimally compressed
  • Use --max-size to force target size

Batch processing stops

Check that all files in directory are valid images/videos. Corrupt files may cause errors.

Advanced Tips

  1. Strip metadata for privacy (default behavior)
  2. Use WebP for best web compression
  3. 720p height is usually enough for mobile viewing
  4. CRF 23 + preset slow gives great results for archiving
  5. Test with one file before batch processing

References

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

ai-image-generator

AI 图片与视频异步生成技能,调用 AI Artist API 根据文本提示词生成图片或视频,自动轮询直到任务完成。 ⚠️ 使用前必须设置环境变量 AI_ARTIST_TOKEN 为你自己的 API Key! 获取 API Key:访问 https://staging.kocgo.vip/index 注册登录后创建。 支持图片模型:SEEDREAM5_0(默认高质量图片)、NANO_BANANA_2(轻量快速)。 支持视频模型:SEEDANCE_1_5_PRO(文生视频,支持音频)、SORA2(文生视频或首尾帧图生视频,支持 firstImageUrl/lastImageUrl)。 触发场景: - 用户要求生成图片,如"生成一匹狼"、"画一只猫"、"风景画"、"帮我画"等。 - 用户要求生成视频,如"生成视频"、"用 SORA2 生成"、"文生视频"、"图生视频"、"生成一段...的视频"等。 - 用户指定模型:SEEDREAM5_0、NANO_BANANA_2、SEEDANCE_1_5_PRO、SORA2。

Archived SourceRecently Updated
General

fosun-skills-setup-guide

复星财富 OpenAPI 技能集(fosun-skills)的安装引导与安全提示说明。当用户首次安装 fosun-skills、或对 ClawHub 安装过程中的安全风险提示有疑问时使用。

Archived SourceRecently Updated
General

humanizer

Remove signs of AI-generated writing from text. Use when editing or reviewing text to make it sound more natural and human-written. Based on Wikipedia's comprehensive "Signs of AI writing" guide. Detects and fixes patterns including: inflated symbolism, promotional language, superficial -ing analyses, vague attributions, em dash overuse, rule of three, AI vocabulary words, negative parallelisms, and excessive conjunctive phrases.

Archived SourceRecently Updated
General

Drawing

Generate children's drawings and coloring pages with modular prompts, style packs, and print-ready constraints across image models.

Archived SourceRecently Updated