function running_total ()
{
awk -v offset=$offset '{
for (i=1; i<=NF; i++) if (s=s+$i) printf("%s ",s);printf ("\n")}'
}
for ((s=0; s<=NUM_FILES; s++)); do
CHAPT_INTERVALS=( ${CHAPT_INTERVALS[@]} "$(awk_math ${VID_LEN[s]} by ${CHAPTERS[s]} float)" )
L=( ${L[@]} $(for ((i=1; i<=${CHAPTERS[s]}; i++)) ; do echo "${CHAPT_INTERVALS[s]}";done) )
chapt_intervals=$(running_total <<< ${L[@]})
chapters="$(for c in $chapt_intervals; do echo $(format_seconds $c); done)"
chapters="00:00:00.000 $chapters"
if [ ${CHAPTERS[s]} = 1 ]; then chapters="00:00:00.000"; fi
CHAPTS=$(for i in $chapters; do echo -n $i,;done)
CHAPT_ARRAY[s]="${CHAPTS%?}"