Crossfading Video AND Audio with ffmpeg
This will do both audio and video:
ffmpeg -i segment1.mp4 -i segment2.mp4 -an \
-filter_complex \
" [0:v]trim=start=0:end=9,setpts=PTS-STARTPTS[firstclip];
[1:v]trim=start=1,setpts=PTS-STARTPTS[secondclip];
[0:v]trim=start=9:end=10,setpts=PTS-STARTPTS[fadeoutsrc];
[1:v]trim=start=0:end=1,setpts=PTS-STARTPTS[fadeinsrc];
[fadeinsrc]format=pix_fmts=yuva420p,
fade=t=in:st=0:d=1:alpha=1[fadein];
[fadeoutsrc]format=pix_fmts=yuva420p,
fade=t=out:st=0:d=1:alpha=1[fadeout];
[fadein]fifo[fadeinfifo];
[fadeout]fifo[fadeoutfifo];
[fadeoutfifo][fadeinfifo]overlay[crossfade];
[firstclip][crossfade][secondclip]concat=n=3[output];
[0:a][1:a] acrossfade=d=1 [audio]
" \
-map "[output]" -map "[audio]" result.mp4
This is basically the same as this answer, which however only cover the video. DO checkout the answer, because it's fantastically explained.
Hopefully they will add a vcrossfade
filter in the future...!