diff options
Diffstat (limited to 'Tools/schnitt/lmplex')
-rwxr-xr-x | Tools/schnitt/lmplex | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Tools/schnitt/lmplex b/Tools/schnitt/lmplex new file mode 100755 index 0000000..8cbb50f --- /dev/null +++ b/Tools/schnitt/lmplex @@ -0,0 +1,51 @@ +#! /usr/bin/perl + +### Calculate the number of CPUs we want to keep busy +open IN, "/proc/cpuinfo"; +$cpus = grep /processor.*:/, <IN>; +close IN; + +### This is a list of files to encode +@names = @ARGV; + +$dira = shift @names; +$dirb = shift @names; + +### This is the name of the encoder to use. +$coder = "/usr/local/bin/mplex "; +### + +### +### +### + +# Encode a single file +sub do_one { + my($m2v) = shift; + # Make mp3 from wav + $m2v =~ s/\.m2v$//; + + # In a subprocess, encode the file + printf "Multiplexing ${m2v}\n"; + unless($pid = fork) { + system ("$coder ${dira}/${m2v}.m2v ${dira}/${m2v}.mp2 ${dirb}/${m2v}.mpg"); + exit; + } +} + +# Go ahead and prefork $cpus encoders +foreach $i (0 .. $cpus-1) { + &do_one($names[0]) if ($names[0] ne ""); + shift @names; +} + +# Wait for the end of each encoder, start a new one... +foreach $i (@names) { + wait; + &do_one($i); +} + +# Wait for everything to close down. +while(wait > 0) { + ; +} |