A lightweight video optimizer written in Python that uses FFmpeg to compress video files while keeping good visual quality.
- Compress any FFmpeg-readable video to a MP4
- Quality-driven encoding via CRF (not fixed bitrate)
- Selectable encoding speed presets (
ultrafast…veryslow) - Sane streaming defaults:
- H.264 (
libx264),yuv420p, High profile, level 4.0 - AAC audio, 96 kbps, stereo
+faststartfor progressive playback
- H.264 (
- Reports size before/after and the percentage saved
- Written in pure Python (standard library only)
- Python 3.10+ (uses
list[str]/Literaltype syntax) - FFmpeg available in
PATH
# Debian / Ubuntu
sudo apt install ffmpeg
# Arch Linux
sudo pacman -S ffmpeggit clone https://github.com/th0truth/ffmpeg-optimizer.git
cd ffmpeg-optimizerpython main.py -f <input> -o <output> [--crf N] [-p PRESET]Example:
python main.py -f input.mkv -o out/input.mp4 --crf 20 -p slow| Option | Default | Description |
|---|---|---|
-f, --filename |
— | Path to the source file (required) |
-o, --output |
— | Path for the optimized file (required) |
--crf |
23 |
Quality, lower is better (18–28) |
-p, --preset |
slow |
Compression speed setting |
| CRF | Result |
|---|---|
18 |
Near-visually-lossless, largest file |
20–23 |
Good quality, recommended range |
26–28 |
Noticeably softer, smallest file |
Slower presets produce smaller files at the same CRF, at the cost of encode time.
| Code | Meaning |
|---|---|
0 |
Optimized successfully |
1 |
Encoding failed |
Released under the MIT License.