Skip to content

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.

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.

Before you can use compression, you need to install the required tools:

Linux:

Terminal window
# Arch Linux / Manjaro
paru -S libjxl
# or
sudo pacman -S libjxl
# Debian / Ubuntu
sudo apt install libjxl-tools

Windows:

Terminal window
winget install --id=libjxl.libjxl -e

macOS:

Terminal window
brew install jpeg-xl

Linux:

Terminal window
# Arch Linux / Manjaro
paru -S ffmpeg
# or
sudo pacman -S ffmpeg
# Debian / Ubuntu
sudo apt install ffmpeg

Windows:

Terminal window
winget install ffmpeg

macOS:

Terminal window
brew install ffmpeg

Use the built-in CLI subcommand:

Terminal window
./kemono-scraper compress

This scans all downloads-* folders in the current directory and compresses eligible files.

If you are running from source instead of a packaged binary:

Terminal window
bun run compress

You can customize compression via CLI flags or environment variables. CLI flags take precedence over environment variables.

Terminal window
./kemono-scraper compress \
--jpegXlQuality 95 \
--jpegXlEffort 7 \
--av1Crf 28 \
--av1Preset 6 \
--no-keepOriginals
Terminal window
JPEG_XL_QUALITY=95 AV1_CRF=28 ./kemono-scraper compress
VariableDefaultDescription
JPEG_XL_QUALITY90JPEG XL quality (1-100, higher = better quality)
JPEG_XL_EFFORT5Encoding effort (1-9, higher = slower but smaller files)
AV1_CRF30AV1 quality (lower = better, 18-35 typical range)
AV1_PRESET6SVT-AV1 preset (0-13, lower = slower but better quality)
KEEP_ORIGINALS1Keep original files after compression (1 = keep, 0 = remove)
  • 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
  • Lower (1-3): Fast encoding, larger files
  • Default (7): Good balance
  • Higher (8-9): Slow encoding, smallest files
  • Lower (18-25): Higher quality, larger files
  • Default (30): Good balance
  • Higher (31-35): Lower quality, smaller files
  • Lower (0-3): Slowest encoding, best quality
  • Default (6): Good balance
  • Higher (10-13): Fast encoding, slightly lower quality

For maximum quality (larger files):

Terminal window
JPEG_XL_QUALITY=98 JPEG_XL_EFFORT=9 AV1_CRF=25 AV1_PRESET=4 ./kemono-scraper compress

For smallest file sizes (some quality loss):

Terminal window
JPEG_XL_QUALITY=85 JPEG_XL_EFFORT=9 AV1_CRF=32 AV1_PRESET=8 ./kemono-scraper compress

The default settings provide a good balance:

Terminal window
./kemono-scraper compress

To automatically remove original files after successful compression:

Terminal window
KEEP_ORIGINALS=0 ./kemono-scraper compress
  1. The script scans your download directories for uncompressed files
  2. Images (JPG/JPEG) are converted to .jxl format
  3. Videos (MP4/MKV) are converted to _av1.mp4 format
  4. By default, original files are preserved alongside compressed versions
  5. On subsequent scraper runs, compressed files are detected and skipped

Make sure libjxl is installed and in your PATH. Verify with:

Terminal window
which cjxl

Install ffmpeg and ensure it’s in your PATH:

Terminal window
which ffmpeg
  • Lower JPEG_XL_EFFORT (try 5-6)
  • Increase AV1_PRESET (try 8-10)
  • Process files in smaller batches
  • Lower JPEG_XL_QUALITY (try 85-90)
  • Increase AV1_CRF (try 32-35)
  • Increase JPEG_XL_QUALITY (try 95-98)
  • Lower AV1_CRF (try 25-28)