0

Sorry for this silly question, but I hardly understand the mapping of input files in ffmpeg.

I use fading effect for a slideshow and a single audio file as

ffmpeg -loop 1 -i image.png -i 1.mp3 -i 2.mp3 -i 3.mp3 -i 4.mp3 -i 5.mp3 \ 
-filter_complex 'concat=n=5:v=0:a=1' -c:v libx264 -tune stillimage \
-c:a aac -vf format=yuv420p -r 25 -shortest out.mp4

How can I create fade in/out effect in the beginning and end of the video?

llogan
  • 57,139
  • 15
  • 118
  • 145
Googlebot
  • 1,032
  • 3
  • 17
  • 34

1 Answers1

1

Use the fade and afade filters. Assuming the output duration is 100 seconds:

ffmpeg -loop 1 -framerate 25 -i image.png -i 1.mp3 -i 2.mp3 -i 3.mp3 -i 4.mp3 -i 5.mp3 -filter_complex "[0]fade=t=in:d=1,fade=t=out:d=1:st=99,format=yuv420p[v];[1:a][2:a][3:a][4:a][5:a]concat=n=5:v=0:a=1,afade=t=in:d=1,afade=t=out:d=1:st=99[a]" -map "[v]" -map "[a]" -c:v libx264 -tune stillimage -c:a aac -shortest -movflags +faststart out.mp4
llogan
  • 57,139
  • 15
  • 118
  • 145
  • so I have to calculate the sum of audio durations before composing the command? – Googlebot Apr 16 '20 at 07:34
  • 1
    @Googlebot Yes, but you can automate it [with help from `ffprobe`](https://superuser.com/a/945604/) and simple scripting. – llogan Apr 16 '20 at 17:34