This is a simple tutorial where I will talk about a simple Python script that you can use to remove silent parts from a video. Remsi is name of the script and it basically generates a FFmpeg command after taking a video as input. Later you can run that command to remove silent parts from video and generate a final video output.
Basically, FFmpeg can’t directly remove silence from a video. It only has functions for detecting silence. But this Remsi script acts as a helper tool in recording those silent parts in the video intelligently remove them using the FFmpeg itself. The script collects the silent parts and then internally generates a combined FFmpeg command which will do the actual work.
We have covered an online tool to remove silent parts from video before. But if FFmpeg can do that as well then you will not need online tools as you will be able to do that locally on your PC. And that’s why here I will walk you through a step-by-step process to do that.
How to Remove Silent Parts from Video using FFmpeg?
In order to use this Remsi script, you have to make sure that you have Python installed. Also, make sure that FFmpeg is in PATH and accessible from PowerShell or Terminal. Here I am using it on Windows but the process is the same on macOS and Linux.
- Clone the GitHub repository of Remsi and cd into its directory.
- Move the input video file in the same folder where the “remsi.py” file is.
- Now, open PowerShell or command prompt in the same folder and run the command below. Replace the Input_File and Output_File with the input file name and output file name respectively.
ffmpeg -i Input_File -hide_banner -af silencedetect=n=-50dB:d=1 -f null – 2>&1 | python remsi.py > Output_File
- Open the output file and then you will find the generated FFmpeg command in it. The command is long and you just copy it and paste it in the terminal.
- The long FFmpeg command will generate the final video with silent parts all removed.
This is how you can use Remsi script to use FFmpeg to remove silent parts from a video. It is very simple to use it and one of the best things about it is you can use it to remove sounds of specific intensity as well. It lets you specify the sound level in decibels in the command to process the input audio file.
Closing words:
FFmpeg is a backbone for thousands of software and tools which involve video processing. And now, one of the best use cases of FFmpeg is in removing silence from videos as well. You can now use it to process the whole lectures and long videos and automatically shorten them by removing silent parts and breaks in just one command. So, give this a try on your own and let me know what you think about it.