Mehul Dudhat
Mehul Dudhat

Reputation: 431

Create MP4 video from multiple images + musics using FFMPEG command

I have created video with multiple images and single music file. It's working fine

ffmpeg -y -framerate 1/5 -start_number 1 -i /<<dir path>>/photo3-%04d.jpg -i /<<dir path>>/music3-000.mp3 -c:v libx264 -r 30 -pix_fmt yuv420p -c:a aac -strict experimental -shortest /<<dir path>>/video/output.mp4;

But when I tried with multiple music files it throws and error in terminal.

Command:

ffmpeg -y -framerate 1/5 -start_number 1 -i /<<dir path>>/photo3-%04d.jpg -i /<<dir path>>/music3-%03d.mp3 -c:v libx264 -r 30 -pix_fmt yuv420p -c:a aac -strict experimental -shortest /<<dir path>>/video/output.mp4;

Error:

/<<dir path>>/music3-%03d.mp3: No such file or directory

Upvotes: 1

Views: 1379

Answers (1)

Gyan
Gyan

Reputation: 93329

There's no audio sequence demuxer. To combine multiple audio files in your command, you'll have to use the concat demuxer.

First, create a text file with the list of files

file 'music3-000.mp3'
file 'music3-001.mp3'
file 'music3-002.mp3'
...

Then run

ffmpeg -y -framerate 1/5 -start_number 1 -i /<<dir path>>/photo3-%04d.jpg \
       -f concat -i list.txt \
       -c:v libx264 -r 30 -pix_fmt yuv420p -c:a aac -strict experimental 
       -shortest /<<dir path>>/video/output.mp4

Upvotes: 2

Related Questions