FFmpeg Concat Demuxer vs Concat Filter for Audio
When combining audio tracks in FFmpeg, choosing between the
concat demuxer and the concat filter directly
dictates processing speed, system resource usage, and final output
fidelity. While the concat demuxer operates at the file
level to splice compatible streams with minimal CPU overhead, the
concat filter decodes, buffers, and re-encodes raw audio in
memory, trading performance for format flexibility. Understanding these
performance differences ensures you select the most efficient pipeline
for your specific audio workflow.
CPU Utilization and Processing Speed
The most significant performance difference lies in CPU load and processing time:
- Concat Demuxer (
-f concat): When used with stream copying (-c copy), the demuxer does not decode or re-encode the audio streams. It simply reads packets from the input files sequentially and writes them into the target container. This results in negligible CPU utilization and execution speeds that are bound almost entirely by disk read/write bandwidth. Processing multiple hours of audio often takes only a few seconds. - Concat Filter
(
-filter_complex concat): The filter operates within FFmpeg's filtergraph, requiring all input streams to be completely decoded into uncompressed pulse-code modulation (PCM) audio, processed, and then re-encoded into the destination format. Because encoding algorithms (such as AAC, MP3, or Opus) are computationally expensive, CPU usage spikes heavily, and the operation proceeds substantially slower than a demuxer stream copy.
Memory Overhead
The memory footprints of the two approaches differ based on how files are opened and buffered:
- Concat Demuxer: Operates sequentially. It opens and reads one file at a time from a text manifest, keeping memory usage flat, minimal, and predictable regardless of how many files are being concatenated.
- Concat Filter: Requires every input file to be
declared as an individual input
(
-i input1.wav -i input2.wav ...) and held within the filtergraph. For joining hundreds or thousands of files, this requires allocating substantial memory for demuxers, decoders, and audio frame buffers, which can lead to system memory exhaustion or file descriptor limit errors.
Audio Transcoding and Generation Loss
- Concat Demuxer: Avoids generation loss entirely
when using
-c copy, as the original encoded bits remain untouched. If transcoding is required (for instance, by omitting-c copy), performance slows down, but the overhead is still generally lower than constructing a multi-input filtergraph. - Concat Filter: Re-encoding is mandatory. Passing lossy formats through the filtergraph introduces generation loss and requires real-time sample rate and bit-depth matching, adding floating-point math operations to the processing pipeline.
Flexibility vs. Constraints
The extreme performance advantage of the concat demuxer
comes with strict operational limits:
- Demuxer Requirements: All input files must share the exact same codec, sample rate, channel layout, bit depth, and time base. Minor differences in packet timestamps or stream headers can cause desynchronization or corrupted output.
- Filter Flexibility: The
concatfilter safely reconciles mismatches in channel counts, sample rates, or codecs using supplementary filters (likearesampleoraformat). It also ensures clean transitions and continuous timestamps, preventing clicks or desyncs at splice points.
Summary: Choosing the Right Tool
Use the concat demuxer when
performance, batch scalability, and lossless processing are critical,
and your source files are known to have identical audio parameters.
Use the concat filter only when source
files have mismatched formats, channels, or sample rates that require
active resampling, or when complex crossfading and audio processing must
happen during the join operation.