apply_files output is incorrect sequence

Well, here I go again.

I looked through the forum to try and make sure this thread isn’t a duplicate issue.

Here’s the situation:

I have 217 .png frames titled f1-f217

When I use this code: gmic apply_files \"f*.png\",\"samj_Barbouillage_Paint_Daub 2,2,100,0.2,1,10,1,0,8\",0,-1,1,\"o.png\"

The frames are rendered and output in the wrong order, jumping to seemingly random frames, inconsistently.

I’ve verified that the input frames are indeed numbered correctly.

Any help would be greatly appreciated.

Is this because your numbering isn’t consistently 3 digits long?

I.e., f001.png, f002.png, …, f217.png.

1 Like


apply_files : "filename_pattern",_"command",_first_frame>=0,_last_frame={ >=0 | -1=last },_frame_step>=1,_output_filename

you can try _first_frame=1000

1 Like

Confirm what @afre observes. If I zero-pad to a consistent-length: f0000.png, f0001.png, f0002.png,…f9999.png, my animation frames are correctly ordered and processed in order. In contrast, f0.png, f1.png,…f37.png,…f527.png,…,f9999.png are not processed in order. f10.png is processed before f2.png, for example, as in string, not numeric sorting.

1 Like


Thank you for pointing this out. I really am amazed by my own ignorance sometimes.

I guess what I know need to figure out how to do, is have ffmpeg split a video into png files with correct numbering for this use case.

Does anyone in this thread have any experience with this/know what I’m referring to?



With ffmpeg: ffmpeg -i -vf fps=29.97 f%6d.png

will create frames numbered sequentially with 6 digits after the letter “f”, for example.

Thanks a lot for the help everybody!

That mainly because *.png create a list of filenames sorted lexically, so file20.png is just after file2.png, with this order.
It’s usually better to deal with fixed-size numbers, left-padded with 0 if necessary :slight_smile:
(for G’MIC, but also many other command-line tools).

1 Like