reduce background noise and optimize the speech from an audio clip using ffmpeg

08
2014-07
  • Sudh

    I extract audio clips from a video file for speech recognition. These videos come from mobile/other handmade devices and hence contain a lot of noise. I want to reduce background noise of the audio so that the speech is clear which I can then relay to my speech recognition engine. I am using ffmpeg to doall this stuff, but am stuck at noise reduction phase. Till now I have tried following filters:

    ffmpeg-20140324-git-63dbba6-win64-static\bin>ffmpeg -i i nput.wav -filter_complex "highpass=f=400,lowpass=f=1800" out2.wav
    
    ffmpeg -i i nput.wav -af "equalizer=f=1000:width_type=h:width=900:g=-10" output.wav
    
    ffmpeg -i i nput.wav -af "bandreject=f=1200:width_type=h:width=900:g=-10" output.wav
    

    But all the results are very disappointing. MY reasoning was that since speech comes under 300-3000 hz range I can filter out all other frequencies to suppress any background noise. What am I missing?

    Also, I read about weiner filters that could be used for speech enhancements and found this https://www.ffmpeg.org/doxygen/0.6/wmavoice_8c-source.html but am not sure how to use this

  • Answers
  • Prajjwal

    Ffmpeg has an -absf option that accepts a bitstream_filter. One of the available bitstream filters is "noise". Try the following:

    ffmpeg -i <input_file> <your_options> -absf noise <output_file>
    

  • Related Question

    FFMPEG add audio to a video but clip it to the video length
  • Daniel Lloyd-Wood

    I'm trying to create a video from an image sequence and add audio with FFMPEG

    The frame sequence is only 25 frames long but the audio is several minutes. I want FFMPEG to clip the audio to the length of the frame sequence.

    This is the command I have tried:

    ffmpeg -i input_images%04d.jpg -pix_fmt yuv420p -vcodec mjpeg -qmin 1 -qmax 1 -r 25 -i audio_file.mp3 -ar 22050 -ab 192k -aframes 25 output.mov
    

    This results in a video with the first image sequence but the full length audio. -aframes is ignored. Any ideas?


  • Related Answers
  • Steven Penny

    From FFmpeg doc

    ffmpeg -i in%04d.jpg -i in.mp3 -shortest out.mov
    


    Finish encoding when the shortest input stream ends.