天天看点

FFmpeg和Audacity噪声处理

FFmpeg噪声处理

FFmpeg 现在有3个原生filter来处理噪声背景:

  • afftdn:使用FFT对音频样本进行降噪
  • anlmdn:使用非局部均值算法减少音频样本中的宽带噪声
  • arnndn:使用递归神经网络减少语音中的噪音。可以在此处找到要加载的模型文件示例。

highpass & lowpass

将低通滤波器与高通滤波器结合使用。对于可用音频,我注意到过滤掉200hz及以下频率和过滤掉3000hz及以上频率,可以很好地保持可用的语音音频。

ffmpeg -i <input_file> -af "highpass=f=200, lowpass=f=3000" <output_file>

# 一个不错的组合过滤器:

ffmpeg -i <input_file> -af lowpass=3000,highpass=200,afftdn=nf=-25 <output_file>

           

anlmdn

$ ffmpeg -h filter=anlmdn

Filter anlmdn
  Reduce broadband noise from stream using Non-Local Means.
    slice threading supported
    Inputs:
       #0: default (audio)
    Outputs:
       #0: default (audio)
anlmdn AVOptions:
   strength          <float>      ..F.A....T. set denoising strength (from 1e-05 to 10) (default 1e-05)
   s                 <float>      ..F.A....T. set denoising strength (from 1e-05 to 10) (default 1e-05)
   patch             <duration>   ..F.A....T. set patch duration (default 0.002)
   p                 <duration>   ..F.A....T. set patch duration (default 0.002)
   research          <duration>   ..F.A....T. set research duration (default 0.006)
   r                 <duration>   ..F.A....T. set research duration (default 0.006)
   output            <int>        ..F.A....T. set output mode (from 0 to 2) (default o)
     i               0            ..F.A....T. input
     o               1            ..F.A....T. output
     n               2            ..F.A....T. noise
   o                 <int>        ..F.A....T. set output mode (from 0 to 2) (default o)
     i               0            ..F.A....T. input
     o               1            ..F.A....T. output
     n               2            ..F.A....T. noise
   smooth            <float>      ..F.A....T. set smooth factor (from 1 to 15) (default 11)
   m                 <float>      ..F.A....T. set smooth factor (from 1 to 15) (default 11)
           

例子:

# 低通和高通滤波器与 afftdn 的组合令人印象深刻,我已经使用此配置成功地从白噪声中清除了旧的 vhs 视频:

-af "highpass=200,lowpass=3000,afftdn"


           

anlmdn

$ ffmpeg -h filter=anlmdn

Filter afftdn
  Denoise audio samples using FFT.
    slice threading supported
    Inputs:
       #0: default (audio)
    Outputs:
       #0: default (audio)
afftdn AVOptions:
   nr                <float>      ..F.A....T. set the noise reduction (from 0.01 to 97) (default 12)
   nf                <float>      ..F.A....T. set the noise floor (from -80 to -20) (default -50)
   nt                <int>        ..F.A...... set the noise type (from 0 to 3) (default w)
     w               0            ..F.A...... white noise
     v               1            ..F.A...... vinyl noise
     s               2            ..F.A...... shellac noise
     c               3            ..F.A...... custom noise
   bn                <string>     ..F.A...... set the custom bands noise
   rf                <float>      ..F.A....T. set the residual floor (from -80 to -20) (default -38)
   tn                <boolean>    ..F.A....T. track noise (default false)
   tr                <boolean>    ..F.A....T. track residual (default false)
   om                <int>        ..F.A....T. set output mode (from 0 to 2) (default o)
     i               0            ..F.A....T. input
     o               1            ..F.A....T. output
     n               2            ..F.A....T. noise
           

arnndn

ffmpeg -h filter=arnndn

Filter arnndn
  Reduce noise from speech using Recurrent Neural Networks.
    slice threading supported
    Inputs:
       #0: default (audio)
    Outputs:
       #0: default (audio)
arnndn AVOptions:
   model             <string>     ..F.A....T. set model name
   m                 <string>     ..F.A....T. set model name
   mix               <float>      ..F.A....T. set output vs input mix (from -1 to 1) (default 1)
           

例子:

# -af arnndn=m=cb.rnnn

ffmpeg -i <input_file> -af arnndn=m=cb.rnnn <output_file>

           

不需要频带滤波器。此处提供经过训练的模型 ( files.rnnn) (您需要下载并使用其中一个文件)。发现cb( conjoined-burgers) 模型最令人印象深刻和最通用的模型,并且非常有效。

audacity去噪

Audacity 是一款用于混音、剪接及音频文件编辑的应用。可以支持各种格式—包括 MP3 和 OGG。我们可以从软件中心安装 Audacity。

当然了,你也可通过命令行来安装:

sudo dnf install audacity
           

安装启动 Audacity 后,在菜单栏选择 文件(File)> 导入(Import) 导入你的音频文件。

接着,从背景噪音中取一段样本以备过滤。在导入的音轨上,选择一段只包含了背景噪音的区域。然后从菜单栏选 效果(Effect)> 降噪(Noise Reduction),然后点击 取得噪音特征(Get Noise Profile)。

接着选择音轨中你想要进行降噪的区域,可以用鼠标选择部分区域或者 Ctrl + A 全选。从菜单中再次选择 效果(Effect)> 降噪(Noise Reduction),在对话框中点击确定就可以完成噪音过滤。

参考

http://ffmpeg.org/ffmpeg-filters.html#afftdn

http://ffmpeg.org/ffmpeg-filters.html#anlmdn

http://ffmpeg.org/ffmpeg-filters.html#arnndn

https://www.vacing.com/ffmpeg_audio_filters/index.html

https://zh.fedoracommunity.org/2018/05/22/Audacity-quick-tip-quickly-remove-background-noise.html