简体   繁体   中英

Crossfading between two audio files with ffmpeg?

I have two mp3 files and want to concatenate them to one new file. However, I want only a part of each file, and I would like to create a cross fade between the two.

So for example I want the first 3 minutes of a.mp3, and then during 5 seconds a crossfade to b.mp3 starting at the 1:20 minute mark (within b.mp3).

Here's a timeline illustration of what I want:

时间线

So the total length of the resulting file would be the 3:05 minutes plus the length of b.mp3 minus 1:25 minutes, which comes down to the length of b.mp3 plus 1:40 minutes.

I am too inexperienced with ffmpeg's source selections, mappings, and filter syntax to get the result I want. For example I can apply a fade in or out to one mp3 file, but I wouldn't know how to make these two overlap, resulting in a crossfade between two audio sources.

Just for clarity: I'm looking for a command line to do this, ie with the standalone version of ffmpeg, I'm not using ffmpeg as library within an application or anything.

Use

ffmpeg -i a.mp3 -i b.mp3
 -filter_complex
      "[0]atrim=0:185.0[a]; [1]atrim=80.0[b];
       [a][b]acrossfade=d=5.0"
 out.mp3

All times are in seconds.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM