4

So I want MEncoder to encode all png files as an avi file from the earliest date modified to the last date modified, and I'd like each frame to be spaced out by 3 seconds.

InquilineKea
  • 6,152
  • 12
  • 43
  • 42

1 Answers1

3

The mf:// syntax says you can pass a listfile, so you can pass a list of files, sorted by date, that way.

To sort your files, if the names are simple enough and they're all in one directory, ls -t will do it: ls -t *.png > file-list.

Then mencoder mf://@file-list -mf fps=1/3:type=png … ought to do it (you can easily check by using mplayer in place of mencoder).

If you need to handle more complicated stuff (e.g., subdirectories), you could use find and perl together. I'm ignoring the possibility of newlines in the filenames, as I doubt mencoder can handle that:

find -type f -name '*.png' | perl -E 'chomp(@a = <>); @a = sort { -M $a <=> -M $b } @a; $,="\n"; say @a'

That's not particularly efficient (it calls stat more than it needs to), but is good enough unless you have a lot of files. Efficiency could be improved by an Orcish Maneuver, Schwartzian transform, etc., if you need many thousands of files.

derobert
  • 107,579
  • 20
  • 231
  • 279