How to Split Audio Streams in FFmpeg with asplit
This article provides a quick guide on how to use the
asplit filter in FFmpeg to duplicate a single audio stream
into multiple identical streams. You will learn the basic syntax of the
filter, see practical command-line examples, and understand how to apply
different effects to each split stream simultaneously.
The asplit filter is used within FFmpeg’s complex
filtergraphs (-filter_complex) to clone an audio input.
This is highly useful when you want to apply different filters to the
same audio source or output the same audio to multiple destinations
without decoding the file multiple times.
Basic Syntax
By default, calling asplit without any arguments
duplicates the input stream into two outputs. The basic syntax is:
asplit [output_stream_1] [output_stream_2]If you need to split the stream into more than two outputs, you must
specify the number of outputs using the outputs parameter
(or simply passing the number as an argument):
asplit=3 [out1] [out2] [out3]Example 1: Splitting Audio into Multiple Output Files
If you want to take an input audio file, split it into two identical streams, and save them as two separate files, use the following command:
ffmpeg -i input.mp3 -filter_complex "[0:a]asplit[a1][a2]" -map "[a1]" output1.mp3 -map "[a2]" output2.mp3In this command: * [0:a] selects the audio stream of the
first input file. * asplit duplicates it into two temporary
streams labeled [a1] and [a2]. *
-map "[a1]" routes the first stream to
output1.mp3. * -map "[a2]" routes the second
stream to output2.mp3.
Example 2: Applying Different Filters to Each Split Stream
The primary benefit of asplit is the ability to process
the same audio source in different ways simultaneously. In the example
below, we split an audio stream into two: one stream gets a volume
boost, while the other stream has a high-pass filter applied.
ffmpeg -i input.wav -filter_complex "[0:a]asplit=2[a1][a2]; [a1]volume=1.5[out1]; [a2]highpass=f=200[out2]" -map "[out1]" louder.wav -map "[out2]" filtered.wavIn this setup: * asplit=2 explicitly defines two
outputs, labeled [a1] and [a2]. *
[a1]volume=1.5[out1] increases the volume of the first
split by 50% and labels the result [out1]. *
[a2]highpass=f=200[out2] cuts frequencies below 200 Hz on
the second split and labels the result [out2]. * Both
processed streams are mapped to their respective output files.