Split Audio into Multiple Streams with FFmpeg asplit
This article provides a straightforward 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, see
practical command-line examples for splitting audio, and understand how
to route these split streams to different outputs or subsequent
filters.
Understanding the asplit Filter
The asplit filter is the audio equivalent of the video
split filter. It takes a single audio input stream and
duplicates it into a specified number of identical output streams. This
is particularly useful when you need to apply different audio effects to
the same source simultaneously or output the same audio to multiple
files or formats.
Basic Syntax
The basic syntax for the asplit filter within a
filtergraph is:
[input_stream] asplit=N [output_stream_1][output_stream_2]...[output_stream_N]
[input_stream]: The input audio stream label (e.g.,[0:a]).asplit=N: The filter name and the number of output streams (N) you want to create. If you omit=N, FFmpeg defaults to2.[output_stream_1]...: The unique labels you assign to each generated output stream.
Practical Examples
Example 1: Splitting Audio into Two Separate Files
If you want to split a single audio file into two identical streams and save them as separate files, use the following 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: Imports
the source audio file. * -filter_complex: Initiates the
complex filtergraph. * [0:a]asplit=2[out1][out2]: Takes the
first audio stream ([0:a]), duplicates it into two streams,
and labels them [out1] and [out2]. *
-map "[out1]" output1.mp3: Directs the first split stream
to output1.mp3. * -map "[out2]" output2.mp3:
Directs the second split stream to output2.mp3.
Example 2: Splitting and Applying Different Filters
A common use case is splitting an audio stream, applying different filters to each clone, and then merging them or saving them separately.
The command below splits an audio stream, applies a highpass filter to the first stream, a lowpass filter to the second stream, and saves them into a single output file with multiple tracks:
ffmpeg -i input.wav -filter_complex "[0:a]asplit=2[a1][a2]; [a1]highpass=f=200[high]; [a2]lowpass=f=3000[low]" -map "[high]" high_output.wav -map "[low]" low_output.wavHow it works: * The filtergraph splits the input
audio into [a1] and [a2]. *
[a1]highpass=f=200[high] applies a highpass filter (cutting
frequencies below 200 Hz) to the first split stream. *
[a2]lowpass=f=3000[low] applies a lowpass filter (cutting
frequencies above 3000 Hz) to the second split stream. * The final
outputs are mapped to their respective destination files.