[LAU] [OT] a sorting problem with AVSynthesis and mencoder

Paul Winkler pw_lists at slinkp.com
Tue Nov 27 09:44:02 EST 2007


On Tue, Nov 27, 2007 at 07:01:11AM -0500, Dave Phillips wrote:
> Greetings,
> 
> I use the following command to invoke mencoder to compile a series of 
> TGA image files into an animation :
> 
> mencoder -ovc lavc -lavcopts vcodec=mpeg4:vme=1:keyint=30:vbitrate=1000 
> -vf scale=800:600 -noskip -mf type=tga:fps=30 -o avs-001.avi mf://*.tga
> 
> 
> (Sorry about the line breaks.)
> 
> The problem starts with the "mf://*.tga" part of the command. When the 
> AVSynthesis program creates its TGA images it saves and labels them 
> sequenctially, i.e. 1.tga, 2.tga, 3.tga and so on, as expected. The 
> problem is that mencoder reads the files as they would be returned by a 
> plain ls command, i.e. 1.tga, 10.tga, 100.tga, 1000.tga, 1001.tga 
> ...101.tga, 1010.tga, thus interpolating frames out of their correct order.

sort(1) combined with xargs(1) should do the trick. Try this:

ls *tga | sort -n | xargs mencoder -ovc lavc -lavcopts vcodec=mpeg4:vme=1:keyint=30:vbitrate=1000 -vf scale=800:600 -noskip -mf type=tga:fps=30 -o avs-001.avi 

> So, my question is, how do I get mencoder to read the TGA files by their 
> time of creation ? That should do the trick, yes ?

To get most recent files last, you could do:

ls -rt *tga | xargs mencoder ...

but I'd stick with sort -n instead, because if you accidentally touch
a file in the middle, it will move to the end of the list...

> Otherwise I have to 
> separate the single digit files from the double digit files and so 
> forth, then I have to create and join separate AVIs. Not terribly 
> difficult, just really annoying and time-consuming.

Or you could use rename(1).  For example:

pw at kermit namegunk $ ls
0.tga   11.tga  13.tga  15.tga  17.tga  19.tga  2.tga  4.tga  6.tga
8.tga
10.tga  12.tga  14.tga  16.tga  18.tga  1.tga   3.tga  5.tga  7.tga
9.tga
pw at kermit namegunk $ rename "" 0 ?.tga
pw at kermit namegunk $ ls
00.tga  02.tga  04.tga  06.tga  08.tga  10.tga  12.tga  14.tga  16.tga
18.tga
01.tga  03.tga  05.tga  07.tga  09.tga  11.tga  13.tga  15.tga  17.tga
19.tga
pw at kermit namegunk $ rename "" 0 ??.tga
pw at kermit namegunk $ ls
000.tga  003.tga  006.tga  009.tga  012.tga  015.tga  018.tga
001.tga  004.tga  007.tga  010.tga  013.tga  016.tga  019.tga
002.tga  005.tga  008.tga  011.tga  014.tga  017.tga

... repeat as necessary.

Having done that, your original comand should work.

-- 

Paul Winkler
http://www.slinkp.com



More information about the Linux-audio-user mailing list