Skip to main content

Compress images, gifs, video, and audio to a target file size using ffmpeg.

Project description

cli-compress

Compress images, gifs, video, and audio to a target file size with ffmpeg.

Requirements

  • Python 3.8+
  • ffmpeg + ffprobe on PATH
    • macOS: brew install ffmpeg
    • Linux: sudo apt install ffmpeg
    • Windows: winget install ffmpeg

Install

pip install -e .

This gives you a compress command on Windows, Linux, and macOS.

Usage

compress input.mp4 -s 10mb
compress photo.png -s 200kb
compress meme.gif -s 3mb
compress song.wav -s 5mb
compress video.mov -s 1gb -o out.mp4
  • -s/--size accepts kb, mb, gb (also kib/mib/gib, same thing) or a raw byte count.
  • -o/--output is optional; defaults to <name>_compressed.<ext>.
  • Lossless audio (.wav, .flac) can't be bitrate-targeted, so it's re-encoded to .mp3 by default.
  • .png has no useful quality knob for size targeting, so it's re-encoded to .jpg by default.

Video and audio use bitrate math against the clip's duration. Images and gifs iteratively shrink resolution (and fps, for gifs) until they fit.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cli_compress-0.1.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cli_compress-0.1.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file cli_compress-0.1.0.tar.gz.

File metadata

  • Download URL: cli_compress-0.1.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for cli_compress-0.1.0.tar.gz
Algorithm Hash digest
SHA256 178f8d17620de04eb0d8913f038a5c65297da6ae04be1d4837e12f2a72ed0178
MD5 0edae8d806919c862a1d79aa24f9a5d1
BLAKE2b-256 5d6a6916e1c6be6ed4877cf86bb27726eacf3b33a15fc02ec05d6512bdce731b

See more details on using hashes here.

File details

Details for the file cli_compress-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cli_compress-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for cli_compress-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90df987b622c72c3f12a4d894d80b072ab608960a0cc2cc729b566a11e2e23f6
MD5 a1973253042ddd69f7c0ebe06c133fbe
BLAKE2b-256 1c87b0e1c3c931f44f1dab4174136eedfaeb1d1fb7cab6f640ee0e8617e360ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page