2

I'm trying to merge audio and picture files on ffmpeg multiple times. For example, this line of code (taken from Combine one image + one audio file to make one video using FFmpeg) allows me to merge one audio and picture file in order to create one mp4:

ffmpeg -loop 1 -i image.jpg -i audio.wav -c:v libx264 -tune stillimage -c:a aac -strict experimental -b:a 192k -pix_fmt yuv420p -shortest out.mp4

I am wondering if it is possible to add a second set of audio and pictures and have them play right after the first set of the audio and picture (Video plays with picture 1 displayed and audio 1 played then it goes over to picture 2 and audio 2). Is this possible?

Robotnik
  • 2,645

1 Answers1

1

You can use the concat filter:

ffmpeg -i 01.jpg -i 01.wav -i 02.jpg -i 02.wav -i 03.jpg -i 03.wav -filter_complex "[0][1][2][3][4][5]concat=n=3:v=1:a=1[vv][a];[vv]format=yuv420p[v]" -map "[v]" -map "[a]" output.mp4

This assumes that all inputs have the same width, height, audio sample rate, number of audio channels, etc. If not you can add more filterchains before using concat.

llogan
  • 63,280