1

I am using ffmpeg to turn a sequence of images (img001.png, img002.png, and so on) into a video (output.mp4) using the following command:

ffmpeg -r 1/5 -i img%03d.png  -r 25 -qscale:v 2 -shortest -codec:a copy output.mp4

The result is a video that displays every input image for five (5) seconds.

  1. Is it possible to have ffmpeg parse the filename paths and timings from a file? I tried the slideshow tutorial on the official ffmpeg website but the output displayed only the last image, briefly, at the end of the video.
  2. Is it possible to bundle audio files with those settings?

For example:

file 'image001.png'
file 'sound001.wav'
duration 5
file 'image002.png'
file 'sound002.wav'
duration 2
file 'image003.png'
file 'sound003.wav'
duration 3

Image001 is displayed for five(5) seconds while sound001 is being played back and so on.

0

The concat demuxer method in the slideshow tutorial is the way to do this. Did you repeat the last image entry once, as mentioned?

Concat demuxer text files specify serial inputs, so can't be used to specify paired or parallel inputs. However, you can always use two text files.

Text file for images:

file 'image001.png'
duration 5
file 'image002.png'
duration 2
file 'image003.png'
duration 3
file 'image003.png'

Text file for sounds:

file 'sound001.wav'
outpoint 5
file 'sound002.wav'
outpoint 2
file 'sound003.wav'
outpoint 3

(For video or audio files, inpoint/outpoint have to be specified to use a trimmed portion of the file)

And with both those files,

ffmpeg -f concat -i images.txt -f concat -i sounds.txt -r 25 -pix_fmt yuv420p out.mp4
  • Thank you very much. This works fine and I integrated it in a Java application I am writing. The only hick-up is that I get a weird error ("Unsafe file name") if I use an absolute path to one of the images/sounds instead of a relative one but I can live with it. :) – melanie93 May 7 '18 at 8:51
  • Change -f concat to -f concat -safe 0 to avoid that issue. – Gyan May 7 '18 at 8:53
  • Oh good. That solved everything. I was chasing my tail for a moment there. xoxo – melanie93 May 7 '18 at 9:11

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.