Use FFmpeg arnndn Filter with Custom RNN Model
The arnndn (Active Recurrent Neural Network Noise
Suppression) filter in FFmpeg is a powerful tool for removing background
noise from audio tracks using neural networks. This guide provides a
straightforward, step-by-step tutorial on how to configure and run the
arnndn filter with a custom RNN model (.rnn)
file to achieve high-quality voice noise reduction.
Step 1: Obtain a Custom RNN Model File
The arnndn filter requires a compatible RNN model file,
typically trained using the RNNoise framework. These files have a
.rnn extension.
You can train your own model or download pre-trained
.rnn files from open-source repositories on platforms like
GitHub (search for “RNNoise models” or “arnndn models”). Common
pre-trained models target specific noise profiles, such as street noise,
office background chatter, or white noise.
Step 2: Basic FFmpeg Command Syntax
To apply the filter with your custom model, use the -af
(audio filter) flag followed by the arnndn filter and the
path to your model file.
The basic syntax is:
ffmpeg -i input.wav -af "arnndn=model='path/to/model.rnn'" output.wavStep 3: Practical Command Examples
For Audio Files
To clean a noisy voice recording (input.wav) and save
the output as clean_output.wav using a model named
speech_model.rnn located in your working directory:
ffmpeg -i input.wav -af "arnndn=model=speech_model.rnn" clean_output.wavFor Video Files
If you are processing a video file (video.mp4) and want
to denoise the audio while keeping the video stream untouched (without
re-encoding the video), run:
ffmpeg -i video.mp4 -af "arnndn=model=speech_model.rnn" -c:v copy clean_video.mp4Note: -c:v copy ensures the video is copied
directly, saving time and preserving video quality.
Path Formatting Tips
- Windows Users: Use forward slashes in your file
paths, or escape the backslashes and drive colons. For example:
arnndn=model='C\:/models/noise_reduction.rnn' - Spaces in Paths: If your file path contains spaces,
wrap the entire filter string in double quotes and the file path in
single quotes:
-af "arnndn=model='/path with spaces/my model.rnn'"