Created
June 23, 2019 13:44
-
-
Save pablocattaneo/0cc66894d7d3690cb9fc2966e6da5b0b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Need a quick, easy and free way of cleaning up a video’s audio from background noise ? Follow the steps below to remove background audio from videos. | |
First get and install the tools: | |
FFMPEG. | |
SoX – Sound eXchange. | |
Then clean your noise! | |
Split the audio and video streams into 2 seperate files: | |
The VIDEO stream: ffmpeg -i input.mp4 -vcodec copy -an tmpvid.mp4 | |
The AUDIO stream: ffmpeg -i input.mp4 -acodec pcm_s16le -ar 128k -vn tmpaud.wav | |
Generate a sample of noise from the audio of the file: | |
ffmpeg -i input.mp4 -acodec pcm_s16le -ar 128k -vn -ss 00:00:00.0 -t 00:00:00.5 noiseaud.wav | |
-ss: the time offset from beginning. (h:m:s.ms). | |
-t duration: the duration (h:m:s.ms) of audio segment to cut that represents the noise. | |
Choose a segment of the audio where there’s no speech, only noise (e.g. speaker was silent for a sec). | |
Generate a noise profile in sox: | |
sox noiseaud.wav -n noiseprof noise.prof | |
Clean the noise samples from the audio stream: | |
sox tmpaud.wav tmpaud-clean.wav noisered noise.prof 0.21 | |
Change 0.21 to adjust the level of sensitivity in the sampling rates (I found 0.2-0.3 often provides best result). | |
Merge the audio and video streams back together: | |
ffmpeg -i tmpvid.mp4 -i tmpaud-clean.wav -map 0:v -map 1:a -c:v copy -c:a aac -b:a 128k out.mp4 | |
I’m thinking of automating this via a web interface that allows uploading a video file, selection of the noise sample and playing with the noisered levels producing a cleaned version… think it’s a useful tool? | |
Thanks for all the contributors in the comments! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment