Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.