DEV Community

Cover image for Fit any video under the limit: meet DeepShrink, a one-command media compressor
Alexander Pervushen for DeepLab

Posted on

Fit any video under the limit: meet DeepShrink, a one-command media compressor

You have a 300 MB screen recording. Discord wants it under 8 MB. Your email won't take more than 20. So you either google "compress video to 8mb" and land on an ad-riddled web converter that uploads your file to someone else's server and stamps a watermark on it — or you open HandBrake and start guessing at CRF values — or you hand-write an ffmpeg command, recompute the bitrate for the fifth time this month, and forget the audio track again.

None of those answer the actual question: "make this ≤ N MB, without me thinking about it."

That's the whole reason DeepShrink exists.

deepshrink gameplay.mp4 --for discord
Enter fullscreen mode Exit fullscreen mode
  gameplay.mp4   1920x1080  2m14s   312.4 MB
  target         Discord (8 MB)
  plan           H.264 · 456 kbps video · 96 kbps audio · two-pass
  ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓  100%   pass 2/2

  ✓ gameplay.shrink.mp4   7.6 MB   (−97.6%)   VMAF 91.2
Enter fullscreen mode Exit fullscreen mode

One command. Local. No upload, no watermark, no guessing. And when you say --target 8MB, the result is guaranteed ≤ 8 MB — not "roughly."

What it actually is

DeepShrink is a small, open-source CLI written in Rust. It doesn't reinvent encoding — it drives ffmpeg for you and does the one thing ffmpeg makes annoying: hitting an exact output size.

Under the hood it probes the file with ffprobe, works out the bitrate budget for your target size (with a little headroom for container overhead), runs a two-pass H.264/H.265 encode for video or picks the right codec bitrate for audio (AAC / Opus / MP3), and can optionally hold a quality floor with VMAF so it never over-compresses. You don't touch any of that. You say how big, it figures out how.

The design goals, in order:

  • One obvious command solves 80% of cases. deepshrink video.mp4 --target 8MB.
  • Presets instead of flags. You shouldn't need to know what a bitrate is.
  • Never wreck the original. Output is a new file (video.shrink.mp4); the source is untouched unless you explicitly pass --overwrite.
  • Local and private. Your file never leaves your machine.

Scope today is video and audio — one engine, ffmpeg. Images, PDFs, and other formats are a deliberate future step, not a half-baked afterthought.

Installing with Homebrew (recommended on macOS)

This is the frictionless path, and it's the one I'd reach for first:

brew install deeplabua/tap/deepshrink
Enter fullscreen mode Exit fullscreen mode

That's it. Because the formula declares depends_on "ffmpeg", Homebrew pulls ffmpeg in as a dependency automatically — so there are zero manual runtime steps. Install, and it works.

If you'd rather tap first and install by short name (handy if you'll install other tools from the same tap later):

brew tap deeplabua/tap
brew install deepshrink
Enter fullscreen mode Exit fullscreen mode

Verify it landed:

deepshrink --version
deepshrink --help
Enter fullscreen mode Exit fullscreen mode

Updating later is just brew upgrade deepshrink.

Installing with cargo (from crates.io)

If you already live in the Rust toolchain, DeepShrink is on crates.io:

cargo install deepshrink
Enter fullscreen mode Exit fullscreen mode

This compiles from source, so it's slower than the prebuilt Homebrew bottle and you need a Rust toolchain installed. Worth knowing about one difference from the brew path: cargo install does not bring ffmpeg along. DeepShrink expects ffmpeg and ffprobe to be on your PATH, and if they aren't, it exits cleanly (code 3) with a hint rather than crashing.

So on a fresh machine, install ffmpeg alongside it:

# macOS
brew install ffmpeg

# Debian / Ubuntu
sudo apt install ffmpeg

# Windows (Scoop)
scoop install ffmpeg
Enter fullscreen mode Exit fullscreen mode

Then the same check as before:

deepshrink --version
Enter fullscreen mode Exit fullscreen mode

brew vs cargo, quickly

brew install deeplabua/tap/deepshrink cargo install deepshrink
Speed Prebuilt bottle, instant Compiles from source
Rust toolchain needed No Yes
ffmpeg Pulled in automatically You install it yourself
Best for Most people, especially macOS Rust devs who already have the toolchain

Prebuilt binaries for macOS, Linux, and Windows are also attached to every GitHub release if you'd rather not use a package manager at all.

Using it

The headline command — fit a file under an absolute size:

deepshrink big.mp4 --target 8MB
deepshrink talk.wav --target 500KB
Enter fullscreen mode Exit fullscreen mode

Don't want to memorize platform limits? Use a destination preset and DeepShrink applies the right cap:

deepshrink clip.mp4 --for discord        # 8 MB
deepshrink clip.mp4 --for email          # 20 MB
deepshrink clip.mp4 --for telegram       # only recompresses for quality
Enter fullscreen mode Exit fullscreen mode

Built-in presets today: discord, discord-nitro, email, telegram, whatsapp, and web.

Prefer a relative cut instead of a hard ceiling?

deepshrink video.mp4 --reduce 70%        # 70% smaller than the source
Enter fullscreen mode Exit fullscreen mode

Audio is a first-class citizen, not an afterthought — great for podcasts, voice memos, and lectures:

deepshrink lecture.wav --target 10MB
Enter fullscreen mode Exit fullscreen mode
  lecture.wav     stereo 48kHz   58m02s   638.1 MB (PCM)
  target          10 MB
  plan            Opus · ~22 kbps · mono (speech)
  ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓  100%

  ✓ lecture.shrink.opus   9.4 MB   (−98.5%)
Enter fullscreen mode Exit fullscreen mode

Got a whole folder? Batch it — DeepShrink walks the directory, skips files that are already small or unsupported, and prints a summary instead of dying on the first hiccup:

deepshrink ./recordings --recursive
Enter fullscreen mode Exit fullscreen mode

A few flags worth knowing:

  • --dry-run — show the plan (chosen bitrate, expected size) without encoding a thing.
  • --vmaf <n> — hold a quality floor; it won't compress below the VMAF score you ask for.
  • --codec h265 — smaller files at the same quality, when you don't need maximum compatibility.
  • --json — machine-readable output, for scripts and CI.
  • --overwrite — replace the original in place (written atomically via a temp file, so an interrupted run won't corrupt your source).

Why bother, over a web converter?

Because DeepShrink is the intersection people actually want: the precision and privacy of native ffmpeg with the simplicity of a web converter — and none of the downsides of either. Your file stays on your disk. You get an exact size, not an approximation. There are no watermarks, no queues, and no "upload your file to continue." It's one static binary that works offline.

Get it

It's open source and free. If it saves you a trip to a sketchy converter even once, consider dropping a ⭐ on the repo — that's what keeps small tools like this alive.

Try it on that 300 MB file you've been avoiding. --target 8MB. Done.

Top comments (0)