rendered paste body#!/bin/bash
# skeletal outline of proceedure to enable multi-processor support
max_procs=$(grep -cs ^processor /proc/cpuinfo)
mkfifo "$WORK_DIR/enc.fifo" 2>/dev/null
"${TOYUV_CMD[@]}" < "$WORK_DIR/enc.fifo" | "${IMGENC_CMD[@]}" 2>/dev/null &
# make intermediary fifos for images. They will get catted to enc.fifo
for ((n=1; n<=max_procs; n++)); do
[[ ! -e "$WORK_DIR/temp-${n}.ppm" ]] && mkfifo "$WORK_DIR/temp-${n}.ppm"
done
unset num_procs
for ((frame=0; frame<endframe; frame++)); do
((num_procs++)) # how many processes are running
out_ppm="$WORK_DIR/temp-${num_procs}.ppm" # current frame
{ command | command | command "$out_ppm" ; }
impids="$impids $!"
if ((num_procs==max_procs || frame == endframe-1)); then
spin "\rProcessing frame $(($frame + 1)) " >&2
cat "${ppm_fifos[@]}"
wait $impids
unset num_procs ppm_fifos impids
fi
done > "$WORK_DIR/enc.fifo"