FFmpeg asplit Filter for Multiple Audio Outputs
This article explains how to use the asplit filter in
FFmpeg to duplicate an audio stream and route it to multiple outputs.
You will learn the fundamental syntax of the filter, see practical
command-line examples for splitting audio, and understand how to apply
different effects to each split stream before saving them to separate
files.
Understanding the asplit Filter
The asplit filter takes a single audio input and
duplicates it into two or more identical audio outputs. This is highly
useful when you need to output the same audio to multiple files, or when
you want to apply different audio filters (like volume adjustment,
equalization, or echoing) to different streams simultaneously.
The basic syntax for the filter is:
asplit=N
Where N is the number of output streams you want to
create. If you do not specify a number, it defaults to
2.
Basic Example: Splitting Audio into Two Files
To split an audio input into two identical outputs and save them as
separate files, you must use filter_complex to manage the
multiple output streams.
Here is the command:
ffmpeg -i input.mp3 -filter_complex "[0:a]asplit=2[out1][out2]" -map "[out1]" output1.mp3 -map "[out2]" output2.mp3How it works:
-i input.mp3: Specifies the input audio file.-filter_complex: Enables complex filtering, which is required when a filter has multiple inputs or outputs.[0:a]: Selects the audio track of the first input file.asplit=2[out1][out2]: Splitting the input audio into two streams, naming them[out1]and[out2].-map "[out1]" output1.mp3: Maps the first split stream to the first output file.-map "[out2]" output2.mp3: Maps the second split stream to the second output file.
Advanced Example: Applying Different Filters to Split Streams
One of the main benefits of splitting audio is the ability to process each stream differently. In the example below, we split the audio into two streams: one is left untouched (clean), while the other has its volume increased.
ffmpeg -i input.wav -filter_complex "[0:a]asplit=2[clean][to_boost]; [to_boost]volume=2.0[boosted]" -map "[clean]" clean_output.wav -map "[boosted]" boosted_output.wavHow it works:
asplit=2[clean][to_boost]: Splits the input audio into two streams named[clean]and[to_boost].;: Separates the different filterchains within the complex filter graph.[to_boost]volume=2.0[boosted]: Takes the[to_boost]stream, doubles its volume, and labels the resulting stream[boosted].- The command then maps
[clean]toclean_output.wavand[boosted]toboosted_output.wav.
Splitting to Three or More Outputs
If you need to split the audio stream into more than two outputs,
simply increase the value of N and define the corresponding
output labels.
For example, to split an audio stream into three outputs:
ffmpeg -i input.mp3 -filter_complex "[0:a]asplit=3[out1][out2][out3]" -map "[out1]" out1.mp3 -map "[out2]" out2.mp3 -map "[out3]" out3.mp3