7

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
jeet
  • 745
  • 3
  • 10
  • 15
  • 1
    FFmpeg can't automatically "stretch" (or guess) the input frame rate from images so they fill the length of an audio stream. You'll have to calculate. – slhck Feb 04 '13 at 08:31

1 Answers1

0

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
Robert Rowntree
  • 6,230
  • 2
  • 24
  • 43
  • `-bt` is ignored by libx264. Single pass using `-crf` instead of `-b:v` is usually recommended. Two-pass is generally used if a certain output file size is desired. See the [FFmpeg and x264 Encoding Guide](https://ffmpeg.org/trac/ffmpeg/wiki/x264EncodingGuide). – llogan Feb 04 '13 at 19:19