All pastes #254685 Raw Edit

Something

public text v1 · immutable
#254685 ·published 2006-11-22 03:36 UTC
rendered paste body
#!/bin/bash

function get_line_count()
{
awk 'END{print NR}' todisc.log
}

check_stall()
{
    while ps -p $TCODE_PID >/dev/null; do
        lines=$(get_line_count)
        sleep 5
        newlines=$(get_line_count)
        ((newlines == lines)) && sleep 30
        newlines=$(get_line_count)
        if ((newlines == lines)); then
            echo "transcode appears to be stalled"
            echo "We are going to send transcode a HUP and hope for the best"
            sleep 5
            $(kill -0 $TCODE_PID > /dev/null 2>&1) && kill -HUP $TCODE_PID
        fi
    done
}


function run_transcode()
{
    "${TCODE_CMD[@]}" >> "$LOG_FILE.tmp"  2>&1
    sleep 1
}

run_transcode &
sleep .5 # short sleep to allow 1st jpg to appear
TCODE_PID=$(</tmp/tcode.pid)
(
if [ -n "$TCODE_PID" ]; then
    while ps -p $TCODE_PID >/dev/null; do
        sleep $SLEEP # spinner interval
    spin "Seeking in video and creating images: $(find "$JPEG_DIR" \
-maxdepth 1 -name \*.jpg|sort|awk -F / '{ field = $NF }; END{ print field }')"
    done
    echo
    echo "Created $(find "$JPEG_DIR" -maxdepth 1 -name \*.jpg|wc -l) JPEGS of $TOTAL_JPEGS"
    cleanlog 1
else
    cleanlog 1
    runtime_error "Problem creating images from the video."
    exit 1
fi
)