blob: 8cbb50f202a07733e0fb443898889c9502b18e65 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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) {
;
}
|