Re: ffmpeg generate the video from non-sequential images

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: ffmpeg generate the video from non-sequential images

Ayush Narsaria
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
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: ffmpeg generate the video from non-sequential images

Moritz Barsnick
On Mon, Oct 29, 2018 at 14:59:43 +0100, Ayush Narsaria wrote:
> 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

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
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: ffmpeg generate the video from non-sequential images

Ayush Narsaria
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 !



On Mon, Oct 29, 2018 at 4:21 PM Moritz Barsnick <[hidden email]> wrote:

> On Mon, Oct 29, 2018 at 14:59:43 +0100, Ayush Narsaria wrote:
> > 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
>
> 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
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".



--
Ayush Narsaria
PhD Student
VU University, Amsterdam
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: ffmpeg generate the video from non-sequential images

Michael Koch

> 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
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: ffmpeg generate the video from non-sequential images

Carl Eugen Hoyos-2
In reply to this post by Moritz Barsnick
2018-10-29 16:21 GMT+01:00, Moritz Barsnick <[hidden email]>:
> On Mon, Oct 29, 2018 at 14:59:43 +0100, Ayush Narsaria wrote:
>> 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

pattern_glob should be a last resort, better use %d if possible.

> 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

Should be:
$ ffmpeg -start_number 5 -framerate 5 -i res-%d.png out.mp4

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: ffmpeg generate the video from non-sequential images

Moritz Barsnick
In reply to this post by Ayush Narsaria
On Mon, Oct 29, 2018 at 17:29:29 +0100, Ayush Narsaria wrote:
> When I try your suggestion I get this error:

Sorry, as Carl Eugen kindly pointed out, I failed to place the
"-start_number" option as an input option.

> 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".

> 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
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: ffmpeg generate the video from non-sequential images

Ayush Narsaria
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


On Tue, Oct 30, 2018 at 10:12 AM Moritz Barsnick <[hidden email]> wrote:

> On Mon, Oct 29, 2018 at 17:29:29 +0100, Ayush Narsaria wrote:
> > When I try your suggestion I get this error:
>
> Sorry, as Carl Eugen kindly pointed out, I failed to place the
> "-start_number" option as an input option.
>
> > 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".
>
> > 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
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".



--
Ayush Narsaria
PhD Student
VU University, Amsterdam
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".