Home ffmpeg add music to video playing after video
Reply: 1

ffmpeg add music to video playing after video

Anuj TBE
1#
Anuj TBE Published in 2018-01-11 07:05:33Z

I'm using ffmpeg to create slideshow of images.

I have to add music in the backgroup which will be played to the size of the slideshow (slicing audio if audio length is greater than video or repeating audio if audio length is shorter than video)

This is what my script is

ffmpeg -y \
-loop 1 -i in1.png \
-loop 1 -i in2.png \
-loop 1 -i in3.png \
-loop 1 -i in4.png \
-loop 1 -i in5.png \
-filter_complex \
"[0:v]trim=duration=6,fade=t=in:st=0:d=1,fade=t=out:st=5:d=1,setsar=1:1[v0]; \
 [1:v]trim=duration=6,fade=t=in:st=0:d=1,fade=t=out:st=5:d=1,setsar=1:1[v1]; \
 [2:v]trim=duration=6,fade=t=in:st=0:d=1,fade=t=out:st=5:d=1,setsar=1:1[v2]; \
 [3:v]trim=duration=6,fade=t=in:st=0:d=1,fade=t=out:st=5:d=1,setsar=1:1[v3]; \
 [4:v]trim=duration=6,fade=t=in:st=0:d=1,fade=t=out:st=5:d=1,setsar=1:1[v4]; \
 [v0][v1][v2][v3][v4]concat=n=5:v=1:a=0,setsar=1:1[v]" -i music.mp3 -shortest -map "[v]" -aspect 16:9 -r 24 shortSlideshow1234.mp4;

This generates output, but slideshow is silent and there is no music in the video.

LordNeckbeard
2#
LordNeckbeard Reply to 2018-01-11 17:09:27Z

You need to also map the audio:

ffmpeg -y \
-loop 1 -framerate 24 -i in1.png \
-loop 1 -framerate 24 -i in2.png \
-loop 1 -framerate 24 -i in3.png \
-loop 1 -framerate 24 -i in4.png \
-loop 1 -framerate 24 -i in5.png \
-i music.mp3 \
-filter_complex \
"[0:v]trim=duration=6,fade=t=in:st=0:d=1,fade=t=out:st=5:d=1,setsar=1[v0]; \
 [1:v]trim=duration=6,fade=t=in:st=0:d=1,fade=t=out:st=5:d=1,setsar=1[v1]; \
 [2:v]trim=duration=6,fade=t=in:st=0:d=1,fade=t=out:st=5:d=1,setsar=1[v2]; \
 [3:v]trim=duration=6,fade=t=in:st=0:d=1,fade=t=out:st=5:d=1,setsar=1[v3]; \
 [4:v]trim=duration=6,fade=t=in:st=0:d=1,fade=t=out:st=5:d=1,setsar=1[v4]; \
 [v0][v1][v2][v3][v4]concat=n=5:v=1:a=0[v]" -map "[v]" -map 5:a shortSlideshow1234.mp4
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.327948 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO