Two pieces: a surrogate perl script that receives encode command. Streaming server would send this command direct to OS; now, it sends it to perl script which places job in a queue structure (See CPAN File::Queue) . Meanwhile, perl script 2 runs as a background daemon which periodically checks for items in the queue. By default, perl back tic ` operator waits for command to finish, so no danger of daemon starting job n+1 while job n is running; nonetheless, added some file locking code just to be sure.
might add some logging, too, just in case. Could be useful for resubmitting jobs.