Ticket #26454: patch-src-makempg.diff

File patch-src-makempg.diff, 5.1 KB (added by danielb@…, 14 years ago)
  • ./src/makempg

    old new  
    289289# Args: $@ == text string containing complete command-line
    290290# To filter/prettify the subprocess output before writing it to the log file,
    291291# set the LOG_FILTER variable before calling this function, to e.g.
    292 #    LOG_FILTER="sed {s/\r/\n/g}"    # Replace LF with CR/LF
     292#    LOG_FILTER="gsed {s/\r/\n/g}"    # Replace LF with CR/LF
    293293# ******************************************************************************
    294 CRLF="sed {s/\r/\n/g}"  # Turn carriage-returns into newlines
     294CRLF="gsed {s/\r/\n/g}"  # Turn carriage-returns into newlines
    295295FOLD="fold -bs"
    296296function cmd_exec()
    297297{
     
    338338    # based on original file size
    339339    $SLICE && VIDEO_DURATION=$CLIP_LENGTH || VIDEO_DURATION=$V_DURATION
    340340    if test "$VIDEO_DURATION" = "0"; then
    341         CUR_SIZE=$(du -Dck \"$IN_FILE\" | awk 'END{print $1}')
     341        CUR_SIZE=$(gdu -Dck \"$IN_FILE\" | awk 'END{print $1}')
    342342        NEED_SPACE=$(expr $CUR_SIZE \* 2)
    343343        yecho  "The encoding process will require about"
    344344    # Estimate space based as kbps * duration
     
    441441                ;;
    442442            "-safe" )
    443443                shift
    444                 SAFE_AREA=$(echo $1 | sed 's/%//g')
     444                SAFE_AREA=$(echo $1 | gsed 's/%//g')
    445445                ;;
    446446            "-crop" )
    447447                USE_FILTERS=1
     
    452452                USE_FILTERS=1
    453453                shift
    454454                # Parse comma-separated values
    455                 for FILTER in $(echo "$1" | sed 's/,/ /g'); do
     455                for FILTER in $(echo "$1" | gsed 's/,/ /g'); do
    456456                    case "$FILTER" in
    457457                        "none" )
    458458                            DO_DENOISE=false
     
    532532            "-subtitles" )
    533533                shift
    534534                if test -e "$1"; then
    535                     SUBS_FILE=$(readlink -f "$1")
     535                    SUBS_FILE=$(greadlink -f "$1")
    536536                    SUBTITLES="-sub \"$SUBS_FILE\""
    537537                    DO_SUBS=:
    538538                else
     
    675675{
    676676    # Get total size of all output files
    677677    cd "$(dirname "$OUT_FILENAME")"
    678     FINAL_SIZE=$(du -c -k "$OUT_PREFIX"*.mpg | awk 'END{print $1}')
     678    FINAL_SIZE=$(gdu -c -k "$OUT_PREFIX"*.mpg | awk 'END{print $1}')
    679679    test -z $FINAL_SIZE && FINAL_SIZE=0
    680680
    681681    if $FAKE; then
    682682        :
    683683    else
    684684        yecho "Output files:"
    685         du -shc "$OUT_PREFIX".mpg "$OUT_PREFIX".[0-9].mpg 2>/dev/null
     685        gdu -shc "$OUT_PREFIX".mpg "$OUT_PREFIX".[0-9].mpg 2>/dev/null
    686686    fi
    687687
    688688    # Create stats directory if it doesn't already exist.
     
    747747        # get lines with frame= , and print last field with kbit/s removed
    748748        bitrates=$(awk -F= '/^frame=/ {gsub("kbits/s", ""); print $NF}' "$LOG_FILE")
    749749        # get highest value, and remove spaces with sed
    750         bitrates=$(sort -un <<< "$bitrates" | sed 's/^[ \t]*//;s/[ \t]*$//')
     750        bitrates=$(sort -un <<< "$bitrates" | gsed 's/^[ \t]*//;s/[ \t]*$//')
    751751        # average the values.  Add 000, so it is in bits.
    752752        AVG_BITRATE=$(awk '{t+=$0} END{printf "%d\n", t/NR}' <<< "$bitrates")
    753753        AVG_BITRATE=${AVG_BITRATE}000
     
    903903    IN_FILE_TYPE="uri"
    904904else
    905905    IN_FILE_TYPE="file"
    906     IN_FILE=$(readlink -f "$IN_FILE")
     906    IN_FILE=$(greadlink -f "$IN_FILE")
    907907fi
    908908
    909909
     
    928928    OUT_PREFIX="$OUTPUT_DIR/$OUT_PREFIX"
    929929# Otherwise, use the full qualified pathname
    930930else
    931     OUT_PREFIX=$(readlink -f "$OUT_PREFIX")
     931    OUT_PREFIX=$(greadlink -f "$OUT_PREFIX")
    932932    mkdir -p "$(dirname "$OUT_PREFIX")"
    933933fi
    934934
     
    11091109    yecho "Probing video for information. This may take several minutes..."
    11101110
    11111111    # Get an MD5sum of the input file for statistics
    1112     IN_FILE_MD5=$(md5sum "$IN_FILE" | awk '{print $1}')
     1112    IN_FILE_MD5=$(gmd5sum "$IN_FILE" | awk '{print $1}')
    11131113
    11141114    # Assume nothing is compliant unless idvid says so
    11151115    # (these will be overridden by idvid for compliant A/V)
     
    17371737
    17381738# Remove extraneous commas from filter command
    17391739if test -n "$VID_FILTER"; then
    1740     VID_FILTER="-vf $(echo "$VID_FILTER" | sed -e 's/,,/,/g' -e 's/^,//')"
     1740    VID_FILTER="-vf $(echo "$VID_FILTER" | gsed -e 's/,,/,/g' -e 's/^,//')"
    17411741fi
    17421742# ******************************************************************************
    17431743#
     
    21132113# ******************************************************************************
    21142114
    21152115if ! $FAKE; then
    2116     AUDIO_SIZE=$(du -c -b "$AUDIO_STREAM" | awk 'END{print $1}')
    2117     VIDEO_SIZE=$(du -c -b "$VIDEO_STREAM" | awk 'END{print $1}')
     2116    AUDIO_SIZE=$(gdu -c -b "$AUDIO_STREAM" | awk 'END{print $1}')
     2117    VIDEO_SIZE=$(gdu -c -b "$VIDEO_STREAM" | awk 'END{print $1}')
    21182118    # Total size of streams so far (in MBytes)
    21192119    STREAM_SIZE=$(expr \( $AUDIO_SIZE \+ $VIDEO_SIZE \) \/ 1000000)
    21202120    # If it exceeds disc size, add '%d' field to allow mplex to split output
    21212121    if test $STREAM_SIZE -gt $DISC_SIZE; then
    2122         OUT_FILENAME=$(echo "$OUT_FILENAME" | sed -e 's/\.mpg$/.%d.mpg/')
     2122        OUT_FILENAME=$(echo "$OUT_FILENAME" | gsed -e 's/\.mpg$/.%d.mpg/')
    21232123    fi
    21242124fi
    21252125