ffmpeg command to combine audio and images

2019-02-22 09:19发布

I'm trying to achieve something which I earlier thought should be a simple task. Is there a ffmpeg command that can do the following:

convert an audio.wav file to a video, Add some 100 pics (img%d.png) to the video so they "automatically" stretch to fill the entire length of the video.

I don't want to set the frame rate manually because it's either making the audio go ahead or lack behind.

I also don't want the following to happen, which happenned when I used "loop_input":

A short video of images got created, which played fast and then repeated itself for the entire duration of the audio.

Please let me know the command.

I've currently tried the following, but these are not giving me the desired results:

This one makes, but video goes fast and audio is not full:

ffmpeg -i img%d.png -i audio.wav -acodec copy output.mpg

This one makes short video which repeats for full audio duration:

ffmpeg -loop_input -shortest -i img%d.png -i audio.wav -acodec copy output.mpg

This one works nearly, but "-r 4" makes video go slow and audio goes ahead. If I use "-r 5" then audio goes slow, and video goes ahead:

ffmpeg -r 4 -i img%d.png -i audio.wav -acodec copy -r 30 output.mpg

标签: ffmpeg
1条回答
孤傲高冷的网名
2楼-- · 2019-02-22 10:08

measure the time of the audio track and then use -t $audio_duration.

this arg, along with "-loop 1" will stop the mp4 at a time that matches the audio.

you might also try 2 pass technique , including -vcodec libx264 as it works well producing mp4.

and think about the following adjusted for your inputs and record rates:

    -b:v 200k -bt 50k
查看更多
登录 后发表回答