I have two input files (track1.m3 and track2.opus) from which I want to extract four clips and crossfade them in sequence. I arrived at this command based
ffmpeg -hide_banner -y -ss 00:00:00 -i ./track1.mp3 -t 00:04:10 -ss 00:00:00 -i ./track2.opus -t 00:00:20 -ss 00:01:15 -i ./track2.opus -t 00:00:35 -ss 00:06:07 -i ./track2.opus -t 00:00:53 -vn -filter_complex "[0][1]acrossfade=d=2:c1=tri:c2=exp[a01];[a01][2]acrossfade=d=2:c1=tri:c2=exp[a02];[a02][3]acrossfade=d=2:c1=tri:c2=exp[output]" -map "[output]" output.mp3
However, it only produces a file with a duration of 53 seconds, which seems to consist of just the last input (the longest one) with no fading at all:
Input #0, mp3, from './track1.mp3':
Metadata:
encoder : Lavf61.1.100
Duration: 00:04:23.31, start: 0.025057, bitrate: 128 kb/s
Stream #0:0: Audio: mp3 (mp3float), 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavf
Input #1, ogg, from './track2.opus':
Duration: 00:07:12.31, start: 0.007500, bitrate: 109 kb/s
Stream #1:0(eng): Audio: opus, 48000 Hz, stereo, fltp
Metadata:
encoder : Lavf61.1.100
Input #2, ogg, from './track2.opus':
Duration: 00:07:12.31, start: 0.007500, bitrate: 109 kb/s
Stream #2:0(eng): Audio: opus, 48000 Hz, stereo, fltp
Metadata:
encoder : Lavf61.1.100
Input #3, ogg, from './track2.opus':
Duration: 00:07:12.31, start: 0.007500, bitrate: 109 kb/s
Stream #3:0(eng): Audio: opus, 48000 Hz, stereo, fltp
Metadata:
encoder : Lavf61.1.100
Stream mapping:
Stream #0:0 (mp3float) -> acrossfade
Stream #1:0 (opus) -> acrossfade
Stream #2:0 (opus) -> acrossfade
Stream #3:0 (opus) -> acrossfade
acrossfade:default -> Stream #0:0 (libmp3lame)
Press [q] to stop, [?] for help
Output #0, mp3, to 'output.mp3':
Metadata:
TSSE : Lavf61.1.100
Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp
Metadata:
encoder : Lavc61.3.100 libmp3lame
[out#0/mp3 @ 000001e763527380] video:0KiB audio:829KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 0.029701%
size= 829KiB time=00:00:53.00 bitrate= 128.1kbits/s speed= 119x
Do I need to do anything special to get all the clips in sequence with cross-fading?
This is ffmpeg 7.0.1-full_build-www.gyan.dev on Windows 10, in case it helps.
Try moving your -t for your output (the one after the all of the -i inputs) to before your input to make it apply to the input and not the output. Something like this: ffmpeg -hide_banner -y -ss 00:00:00 -t 00:00:53 -i ./track1.mp3 -ss 00:00:00 -t 00:04:10 -i ./track2.opus -ss 00:01:15 -t 00:00:20 -i ./track2.opus -ss 00:06:07 -t 00:00:35 -i ./track2.opus -vn -filter_complex "[0][1]acrossfade=d=2:c1=tri:c2=exp[a01];[a01][2]acrossfade=d=2:c1=tri:c2=exp[a02];[a02][3]acrossfade=d=2:c1=tri:c2=exp[output]" -map "[output]" output.mp3
Try moving your
-t
for your output (the one after the all of the-i
inputs) to before your input to make it apply to the input and not the output.Something like this:
See less