Discussion:
[FFmpeg-user] ffmpeg generate the video from non-sequential images
Ayush Narsaria
2018-10-29 13:59:43 UTC
Permalink
Hello all,

I am quite new to ffmpeg so still learning many things for creating a video
animation for my chemistry project.
I have multiple “res-%d.png” files but when I try to use ffmpeg to generate
a video it starts from a random .png file.
My png files are numbered from res-5.png to res-180.png.

The command I give is :

ffmpeg -framerate 5 -pattern_type glob -i '*.png' -c:v libx264 output.mp4


Please help! Thank you

Best,
Ayush Narsaria
PhD Student
VU University, Amsterdam
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-us
Moritz Barsnick
2018-10-29 15:21:01 UTC
Permalink
Post by Ayush Narsaria
My png files are numbered from res-5.png to res-180.png.
ffmpeg -framerate 5 -pattern_type glob -i '*.png' -c:v libx264 output.mp4
The globbing will probably order your files alphabetically, making
res-1*.png come before res-2.png. resulting in incorrect order.

I suggest:
$ ffmpeg -framerate 5 -i 'res-%d.png' -start_number 5 -c:v libx264 output.mp4
(Untested. Perhaps you need a different "-pattern_type" than glob.)

The numbers must still be sequential though.

Moritz
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org with subje
Ayush Narsaria
2018-10-29 16:29:29 UTC
Permalink
Dear Moritz,

Thank you for replying.
When I try your suggestion I get this error:

Could find no file with path 'res_%d.png' and index in the range 0-4

res_%d.png: No such file or directory


So the filenames start from res_05.png till res_180.png but there are some
files missing in between like res_13.png etc.
Would that be a problem?

Thank you again !
Post by Moritz Barsnick
Post by Ayush Narsaria
My png files are numbered from res-5.png to res-180.png.
ffmpeg -framerate 5 -pattern_type glob -i '*.png' -c:v libx264 output.mp4
The globbing will probably order your files alphabetically, making
res-1*.png come before res-2.png. resulting in incorrect order.
$ ffmpeg -framerate 5 -i 'res-%d.png' -start_number 5 -c:v libx264 output.mp4
(Untested. Perhaps you need a different "-pattern_type" than glob.)
The numbers must still be sequential though.
Moritz
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email
--
Ayush Narsaria
PhD Student
VU University, Amsterdam
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org with subject "unsubscrib
Michael Koch
2018-10-29 17:53:56 UTC
Permalink
Post by Ayush Narsaria
Could find no file with path 'res_%d.png' and index in the range 0-4
res_%d.png: No such file or directory
So the filenames start from res_05.png till res_180.png but there are some
files missing in between like res_13.png etc.
Would that be a problem?
The problem is that you have a leading zero before the number 5.
If you change all numbers to three digits (005, 006 ...) then you can
use -i res_%3d.png
which means %3d is replaced by a 3-digit number.

Michael

_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-
Moritz Barsnick
2018-10-30 09:12:16 UTC
Permalink
Sorry, as Carl Eugen kindly pointed out, I failed to place the
"-start_number" option as an input option.
Post by Ayush Narsaria
res_%d.png: No such file or directory
So the filenames start from res_05.png till res_180.png but there are some
Well, in honesty, you said the name would be res_5.png, not
res_05.png. That's a difference for the "%d" operator. You need to
force min two digits with filling zeros: "%02d".
Post by Ayush Narsaria
files missing in between like res_13.png etc.
Would that be a problem?
Yes. In that case, you would place the list of images in a text file:
file res_05.png
file res_07.png
file res_12.png

and use the concat demuxer:
$ ffmpeg -r 5 -f concat -i in.txt -c:v libx264 output.mp4

(Should work. ;-) I get peculiar DTS warnings though, must investigate.)

Moritz
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-reques
Ayush Narsaria
2018-10-30 09:14:46 UTC
Permalink
Dear Moritz,

Thank you again for replying.

I managed to solve the problem b dividing my images into two parts based on
number of leading zeroes and then concat both of the generated video.
That also works. I will also try your method.

Thank you

Best,
Ayush
Post by Moritz Barsnick
Sorry, as Carl Eugen kindly pointed out, I failed to place the
"-start_number" option as an input option.
Post by Ayush Narsaria
res_%d.png: No such file or directory
So the filenames start from res_05.png till res_180.png but there are
some
Well, in honesty, you said the name would be res_5.png, not
res_05.png. That's a difference for the "%d" operator. You need to
force min two digits with filling zeros: "%02d".
Post by Ayush Narsaria
files missing in between like res_13.png etc.
Would that be a problem?
file res_05.png
file res_07.png
file res_12.png
$ ffmpeg -r 5 -f concat -i in.txt -c:v libx264 output.mp4
(Should work. ;-) I get peculiar DTS warnings though, must investigate.)
Moritz
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email
--
Ayush Narsaria
PhD Student
VU University, Amsterdam
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org with subject "unsubscr
Carl Eugen Hoyos
2018-10-29 20:46:26 UTC
Permalink
Post by Moritz Barsnick
Post by Ayush Narsaria
My png files are numbered from res-5.png to res-180.png.
ffmpeg -framerate 5 -pattern_type glob -i '*.png' -c:v libx264 output.mp4
pattern_glob should be a last resort, better use %d if possible.
Post by Moritz Barsnick
The globbing will probably order your files alphabetically, making
res-1*.png come before res-2.png. resulting in incorrect order.
$ ffmpeg -framerate 5 -i 'res-%d.png' -start_number 5 -c:v libx264 output.mp4
Should be:
$ ffmpeg -start_number 5 -framerate 5 -i res-%d.png out.mp4

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org with subject "un
Loading...