How to automatically cut silence in videos
I mostly communicate using text, but sometimes I make a video, maybe as a coding tutorial, or maybe when I want to say something to my newsletter.
Text is great, but when people see your face in a video and hear your voice, there is a very different kind of connection there.
More than that, there’s just meeting face to face.
I know that because I follow many people on YouTube and I think I’m friends with them, in a uni-directionary way.
Anyway, I’m digressing. While the video format is great, making a video is a pain.
For me, anyway. I am Italian, but I want to communicate in English (a language I only started learning when I was 14).
Plus, I’m not a great speaker. I make mistakes every time, even when I speak in Italian. So I make many mistakes while recording. And this in turn makes editing a pain.
I always end up with a 20 minutes video that i need to edit down to 10 minutes.
I also make many pauses, and I want to cut them in the editing process.
I discovered a tool to help me speed up the process. It automatically removes pauses. Which is great in some kinds of videos.
It might not work for every video, it works best in those videos where you talk all the time. In coding videos where you type code in the editor, it might be a bad idea to use it.
It’s a Python program called jumpcutter, you can find it here: https://github.com/carykh/jumpcutter.
Go into a folder on your computer and run
git clone https://github.com/carykh/jumpcutter.git
Then go into the jumpcutter
folder:
cd jumpcutter
And install the required dependencies:
python -m pip install --user -r requirements.txt
We’re ready to go! Copy your movie into the folder, in my case it’s video.mp4
, and run:
python jumpcutter.py --input_file video.mp4 --silent_speed 999999 --frame_margin 2 --frame_rate 30
To figure out the options you can just read the Python program source code, as it’s just 200 lines: https://github.com/carykh/jumpcutter/blob/master/jumpcutter.py.
In this case, --silent_speed 999999
makes the video cut when there is silence. The program “modifies a video file to play at different speeds when there is sound vs. silence”, so we’re essentially using it at it maximum rate to get a cut.
--frame_margin 2
sets the number of frames around the sound, to avoid cuts that are too “immediate”.
--frame_rate 30
is the video frame rate.
There are more options, but those worked for me.
Also check this video by the author to find out more about this program.
Many thanks to this gist, that’s how I found it.
I tested it on a 24 minutes video and it got reduced down to 14 minutes.
Now half of my editing is done. I just need to remove the takes I shoot 2 or 3 times, and I can finalize the video as I want it.
→ I wrote 17 books to help you become a better developer, download them all at $0 cost by joining my newsletter
→ JOIN MY CODING BOOTCAMP, an amazing cohort course that will be a huge step up in your coding career - covering React, Next.js - next edition February 2025