How to Use FFmpeg asplit to Duplicate Audio Streams
This article explains how to use the asplit filter in
FFmpeg to duplicate a single audio stream into two or more identical,
independent streams. You will learn the correct command-line syntax, see
a practical example of splitting and routing audio, and understand how
to apply different filters to each resulting stream.
The asplit filter is a built-in FFmpeg audio filter
designed to clone an input audio stream. By default, calling
asplit outputs two identical streams, but you can configure
it to output more by passing a specific parameter (e.g.,
asplit=3 for three streams). This is highly useful when you
need to apply different audio effects to the same source or output the
same audio to multiple destination files simultaneously.
Basic Syntax and Command Example
To split an audio stream into two identical streams, you must use
FFmpeg’s -filter_complex flag. This allows you to define
custom labels for the newly created streams and map them to separate
outputs.
Here is a straightforward command to split an audio stream:
ffmpeg -i input.mp3 -filter_complex "[0:a]asplit[out1][out2]" -map "[out1]" output1.mp3 -map "[out2]" output2.mp3Breakdown of the Command
-i input.mp3: Specifies the input audio file.-filter_complex: Tells FFmpeg to use a complex filtergraph, which is required when a filter has multiple outputs.[0:a]: Selects the first audio stream of the first input file.asplit: Calls the audio split filter. Since no number is specified, it defaults to splitting the stream into two.[out1][out2]: These are temporary labels assigned to the two identical output streams generated by the filter.-map "[out1]" output1.mp3: Directs the first split stream to the fileoutput1.mp3.-map "[out2]" output2.mp3: Directs the second split stream to the fileoutput2.mp3.
Processing Split Streams with Different Filters
One of the main reasons to use asplit is to process the
cloned streams differently before saving them. For example, you can
increase the volume of the first stream and apply a lowpass filter to
the second stream:
ffmpeg -i input.wav -filter_complex "[0:a]asplit=2[a1][a2]; [a1]volume=1.5[loud]; [a2]lowpass=f=3000[filtered]" -map "[loud]" output_loud.wav -map "[filtered]" output_lowpass.wavIn this command, asplit=2 explicitly defines the split
into two streams ([a1] and [a2]). The
semicolon separates the different filter chains, allowing you to
manipulate each stream independently before mapping them to their final
files.