f you’re like me, you probably have a ton of videos to deliver for your courses – in my case, it added up to 117GB! That’s a huge strain on storage and inconvenient for sharing or uploading. After some research and experimentation, I found a way to shrink my video files down to 58.44GB without compromising the quality noticeably. That’s nearly a 50% reduction in size! 🎉
The best part? It’s all done using a Python script – automated, efficient, and simple enough for anyone to use.
What the Script Does
In simple terms, this script goes through all the videos in a folder, checks their size, quality, and bitrate, and reduces their size by compressing them intelligently.
Here’s the magic in just a few bullet points:
- Scans all MP4 files in the folder you specify.
- Checks their bitrate (the amount of data used per second of video) and skips the ones already optimized.
- Compresses videos with high bitrate down to a more reasonable size without compromising on quality.
- Uses FFmpeg, a powerful tool used for processing video and audio files.
- Keeps your original folder structure and doesn’t overwrite your files – so it’s completely safe to use.
How I Used the Script
I ran this Python script on my video folder, which was 117GB in size. The script automatically reduced video sizes based on their bitrate, and after running it, my folder was only 58.44GB — less than half the original size!
It saved me weeks of manual work and hours of frustration, trying to optimize each file manually.
How to Use the Script
Here’s how you can use the script yourself. Don’t worry if you’ve never used Python before – I’ll walk you through everything step by step.
1. Install FFmpeg
The script requires FFmpeg, an open-source tool for video processing. You can install it via Homebrew on macOS:
brew install ffmpeg
For other systems, check the official FFmpeg installation guide.
2. Install tqdm
tqdm
is a Python library that shows a nice progress bar while processing your files. To install it, run:
python3 -m pip install --user tqdm
3. Download the Script
I’ve made the script available on this Gist. You can download it directly or copy it into a file named video_processor.py
.
4. Run the Script
Once you’ve downloaded the script, open your terminal or command prompt and run:
python3 video_processor.py "/path/to/your/videos" "/path/to/output/folder"
- Replace
/path/to/your/videos
with the folder where your videos are stored. - Replace
/path/to/output/folder
with the folder where you want the optimized videos to be saved.
The script will go through, compress the videos, and save the resized versions while keeping the original folder structure intact!
The Results
This script was a lifesaver for me! My course videos went from 117GB to 58.44GB, freeing up tons of space while still looking great. Whether you’re a course creator, video editor, or just someone looking to reclaim some storage, this script can work wonders for you too.