Compression
After downloading files, you can compress them to save significant disk space. The scraper includes a built-in compression script that converts images and videos to more efficient formats.
What Gets Compressed
Section titled “What Gets Compressed”The compression script automatically processes:
- Images: JPG/JPEG → JPEG XL (typically 30-50% smaller)
- Videos: MP4/MKV → AV1 (typically 30-50% smaller)
The scraper automatically detects compressed files on subsequent runs, so you won’t re-download files that have already been compressed.
Requirements
Section titled “Requirements”Before you can use compression, you need to install the required tools:
libjxl (for JPEG XL)
Section titled “libjxl (for JPEG XL)”Linux:
# Arch Linux / Manjaroparu -S libjxl# orsudo pacman -S libjxl
# Debian / Ubuntusudo apt install libjxl-toolsWindows:
winget install --id=libjxl.libjxl -emacOS:
brew install jpeg-xlffmpeg (with SVT-AV1 support)
Section titled “ffmpeg (with SVT-AV1 support)”Linux:
# Arch Linux / Manjaroparu -S ffmpeg# orsudo pacman -S ffmpeg
# Debian / Ubuntusudo apt install ffmpegWindows:
winget install ffmpegmacOS:
brew install ffmpegRunning Compression
Section titled “Running Compression”Basic Usage (recommended)
Section titled “Basic Usage (recommended)”Use the built-in CLI subcommand:
./kemono-scraper compressThis scans all downloads-* folders in the current directory and compresses eligible files.
From source (development)
Section titled “From source (development)”If you are running from source instead of a packaged binary:
bun run compressConfiguration
Section titled “Configuration”You can customize compression via CLI flags or environment variables. CLI flags take precedence over environment variables.
CLI Flags
Section titled “CLI Flags”./kemono-scraper compress \ --jpegXlQuality 95 \ --jpegXlEffort 7 \ --av1Crf 28 \ --av1Preset 6 \ --no-keepOriginalsEnvironment Variables
Section titled “Environment Variables”JPEG_XL_QUALITY=95 AV1_CRF=28 ./kemono-scraper compress| Variable | Default | Description |
|---|---|---|
JPEG_XL_QUALITY | 90 | JPEG XL quality (1-100, higher = better quality) |
JPEG_XL_EFFORT | 5 | Encoding effort (1-9, higher = slower but smaller files) |
AV1_CRF | 30 | AV1 quality (lower = better, 18-35 typical range) |
AV1_PRESET | 6 | SVT-AV1 preset (0-13, lower = slower but better quality) |
KEEP_ORIGINALS | 1 | Keep original files after compression (1 = keep, 0 = remove) |
Understanding Quality Settings
Section titled “Understanding Quality Settings”JPEG XL Quality
Section titled “JPEG XL Quality”- Lower values (70-85): Smaller files, slight quality loss
- Default (90): Good balance of quality and size
- Higher values (95-100): Near-lossless, larger files
JPEG XL Effort
Section titled “JPEG XL Effort”- Lower (1-3): Fast encoding, larger files
- Default (7): Good balance
- Higher (8-9): Slow encoding, smallest files
AV1 CRF (Constant Rate Factor)
Section titled “AV1 CRF (Constant Rate Factor)”- Lower (18-25): Higher quality, larger files
- Default (30): Good balance
- Higher (31-35): Lower quality, smaller files
AV1 Preset
Section titled “AV1 Preset”- Lower (0-3): Slowest encoding, best quality
- Default (6): Good balance
- Higher (10-13): Fast encoding, slightly lower quality
Examples
Section titled “Examples”High Quality Compression
Section titled “High Quality Compression”For maximum quality (larger files):
JPEG_XL_QUALITY=98 JPEG_XL_EFFORT=9 AV1_CRF=25 AV1_PRESET=4 ./kemono-scraper compressMaximum Compression
Section titled “Maximum Compression”For smallest file sizes (some quality loss):
JPEG_XL_QUALITY=85 JPEG_XL_EFFORT=9 AV1_CRF=32 AV1_PRESET=8 ./kemono-scraper compressBalanced (Default)
Section titled “Balanced (Default)”The default settings provide a good balance:
./kemono-scraper compressRemove Originals After Compression
Section titled “Remove Originals After Compression”To automatically remove original files after successful compression:
KEEP_ORIGINALS=0 ./kemono-scraper compressHow It Works
Section titled “How It Works”- The script scans your download directories for uncompressed files
- Images (JPG/JPEG) are converted to
.jxlformat - Videos (MP4/MKV) are converted to
_av1.mp4format - By default, original files are preserved alongside compressed versions
- On subsequent scraper runs, compressed files are detected and skipped
Troubleshooting
Section titled “Troubleshooting””Command not found: cjxl”
Section titled “”Command not found: cjxl””Make sure libjxl is installed and in your PATH. Verify with:
which cjxl“ffmpeg: command not found”
Section titled ““ffmpeg: command not found””Install ffmpeg and ensure it’s in your PATH:
which ffmpegCompression is very slow
Section titled “Compression is very slow”- Lower
JPEG_XL_EFFORT(try 5-6) - Increase
AV1_PRESET(try 8-10) - Process files in smaller batches
Files are too large after compression
Section titled “Files are too large after compression”- Lower
JPEG_XL_QUALITY(try 85-90) - Increase
AV1_CRF(try 32-35)
Files are too small / quality is poor
Section titled “Files are too small / quality is poor”- Increase
JPEG_XL_QUALITY(try 95-98) - Lower
AV1_CRF(try 25-28)
Next Steps
Section titled “Next Steps”- Learn about basic usage for downloading files
- See command line options for more control