0

Similar question here, but not yet answered.

Problem:

I'm combining images (.png) of same resolution/size (they all came from the same matplotlib.pyplot), but the resulting video is missing several frames.

Command:

ffmpeg -f image2 -r 1 -i .\\images\\image%02d.png -c:v libx264 -r 30 .\\images\\output.mp4 

Resulting Video

  • Length of 0:09
  • Missing more than half the images

Images

  • .\images
    • image00.png
    • image01.png
    • image02.png
    • image03.png
    • image04.png
    • image05.png
    • image06.png
    • image07.png
    • . . .

Notes:

I followed examples from here. I'm new to using ffmpeg, so I may not be completely sure of what each of the command line options I've used means, though I have a pretty good idea.

Thanks, any help/advice/suggestions will be greatly appreciated. I am also perfectly willing to provide further information that may help resolve this issue.

2 Answers 2

3

Sometimes this happens if the images are not all exactly the same size. Your command looks fine to me.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your reply! They are the same size. I made a silly mistake actually, which I am about to resolve by answering my own question.
1

I saved my images as:

Images

.\images image00.png image01.png image02.png image03.png image04.png image05.png image06.png image08.png image09.png image010.png #<---- crap. all hells gone loose now. image011.png image012.png image013.png image014.png image015.png 

Because I saved them in a for loop and tried to do some fancy name generating script that failed miserably. For reference though, this is the code that works:

for i in range(len(frames)): fig.savefig('images\\' + 'image'+ ('{0:0'+str(len(str(len(frames))))+'}').format(i)+'.png') 

3 Comments

In the future to avoid padding issues, you can use string number formatting like %5d to create your filenames.
Something like print '%4d' % 10, gives me ' 10' rather than '0010' though.
%02d would pad one. i forgot to mention that is a two parameter string format. use 0 instead of spaces to pad a field when the width option is specified. For example, printf("%2d", 3) results in " 3", while printf("%02d", 3) results in "03". so %04d would be 3 leading zeros

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.