Articulating ideas

How To Do Noise Reduction Using ffmpeg And sox

Need a quick, easy and free way of cleaning up a video’s audio from background noise? Follow the steps below.

First get and install the tools:

Then clean your noise!

  1. Split the audio and video streams into 2 seperate files:
    The VIDEO stream: ffmpeg -i input.mp4 -sameq -an tmpvid.mp4
    The AUDIO stream: ffmpeg -i input.mp4 -sameq tmpaud.wav 
  2. Generate a sample of noise from the audio of the file:
    ffmpeg -i input.mp4 -vn -ss 00:00:00 -t 00:00:01 noiseaud.wav
    -ss: the time offset from beginning. (h:m:s.ms).
    -t duration: record or transcode duration seconds of audio/video.
    Choose a segment of the audio where there’s no speech, only noise (e.g. speaker was silent for a sec).
  3.  Generate a noise profile in sox:
    sox noiseaud.wav -n noiseprof noise.prof
  4. 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).
  5. Merge the audio and video streams back together:
    ffmpeg -i tmpaud-clean.wav -i tmpvid.mp4 -sameq vid.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?

Categorised as: ffmpeg, Hack, video


  • Usp71084

    Thanks..I was looking exactly for this. 

  • Karthik

    THanks! this was very useful!! :)

  • Dan LaMotte

    This was very useful. Thanks!

  • http://www.zoharbabin.com Zohar Babin

    thanks for the great feedback :)