Using FFmpeg, I am trying to combine many audio files into one long one, with a crossfade between each of them. To keep the numbers simple, let's say I have 10 input files, each 5 minutes, and I want a 10 second crossfade between each. (Resulting duration would be 48:30.) Assume all input files have the same codec/bitrate.

I was pleasantly surprises to find how simple it was to crossfade two files:

ffmpeg -i 0.mp3 -i 1.mp3 -vn -filter_complex acrossfade=d=10:c1=tri:c2=tri out.mp3

But the acrossfade filter does not allow 3+ inputs. So my naive solution is to repeatedly run ffmpeg, crossfading the previous intermediate output with the next input file. It's not ideal. It leads me to two questions:

1. Does acrossfade losslessly copy the streams? (Except where they're actively crossfading, of course.) Or do the entire input streams get reencoded?

If the input streams are entirely reencoded, then my naive approach is very bad. In the example above (calling acrossfade 9 times), the first 4:50 of the first file would be reencoded 9 times! If I'm combining 50 files, the first file gets reencoded 49 times!

2. To avoid multiple runs and the reencoding issue, can I achieve the many-crossfade behavior in a single ffmpeg call?

I imagine I would need some long filtergraph, but I haven't figured it out yet. Does anyone have an example of crossfading just 3 input files? From that I could automate the filtergraphs for longer chains.

Thanks for any tips!

1 Answer 1


Filters work on raw sample data and output the same. Decoding occurs before data is sent to the filters and encoding occurs after all filtering is done. So, if the filter doesn't modify a portion of the data then that portion remains intact.

In your command, you are outputting to MP3, so this does force a re-encode. You can avoid that by outputting to a WAV,

ffmpeg -i 0.mp3 -i 1.mp3 -vn -filter_complex acrossfade=d=10:c1=tri:c2=tri out.wav

You can output to MP3 during the final crossfade command.

You can also carry out all crossfades in one call.

Example with 4 files,

ffmpeg -i 0.mp3 -i 1.mp3 -i 2.mp3 -i 3.mp3 -vn
       -filter_complex "[0][1]acrossfade=d=10:c1=tri:c2=tri[a01];

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .