All pastes #458925 Raw Edit

Mine

public text v1 · immutable
#458925 ·published 2007-04-26 05:32 UTC
rendered paste body
    # If doing -fast identification, skip "accurate" length determination
    if $FAST; then
        :
    else # make a nav_log: can be reused, especially by todisc for fast seeking
        if hash tcdemux 2>/dev/null; then # use tcdemux if present
            if  [[ ! -e "$INFILE".nav_log ]]; then # only do if no log yet
                if [[ ${INFILE##*.} =~ [MmPpGg] ]]; then # test for *.mpg ext
                    NUM_FRAMES=$(LC_ALL=C tcdemux -i "$INFILE" -W "$INFILE" 2>&1 |
                    tee "$INFILE".nav_log | awk '{ field = $2 }; END{ print field }')
                fi
            else # use existing nav_log
                echo "nav_log exists, using ${INFILE}.nav_log"
                echo "If you don't want to use this file please delete it"
                NUM_FRAMES=$(awk '{ field = $2 }; END{ print field }'  < "${INFILE}".nav_log)
            fi
            V_DUR=$(bc <<< "$NUM_FRAMES / $ID_VIDEO_FPS")
            V_DURATION=${V_DUR%%.*} # final value is integer ( seconds )
        else
            # Determine duration by playing the video into /dev/null and doing
            # tons of filtering. Time consuming, but presumably more accurate.
            V_DURATION=$(LC_ALL=C mencoder -ovc frameno -oac pcm -noskiplimit \
            "$INFILE" -o /dev/null 2>/dev/null | tr '\r' '\n' | grep ^Pos: | \
            tail -n 1 | sed s/^.*Pos:// | awk '{print $1}' | sed s/[.][0-9]s//)
        fi
    fi