Ticket #26454: patch-src-makempg.diff
File patch-src-makempg.diff, 5.1 KB (added by danielb@…, 14 years ago) |
---|
-
./src/makempg
old new 289 289 # Args: $@ == text string containing complete command-line 290 290 # To filter/prettify the subprocess output before writing it to the log file, 291 291 # set the LOG_FILTER variable before calling this function, to e.g. 292 # LOG_FILTER=" sed {s/\r/\n/g}" # Replace LF with CR/LF292 # LOG_FILTER="gsed {s/\r/\n/g}" # Replace LF with CR/LF 293 293 # ****************************************************************************** 294 CRLF=" sed {s/\r/\n/g}" # Turn carriage-returns into newlines294 CRLF="gsed {s/\r/\n/g}" # Turn carriage-returns into newlines 295 295 FOLD="fold -bs" 296 296 function cmd_exec() 297 297 { … … 338 338 # based on original file size 339 339 $SLICE && VIDEO_DURATION=$CLIP_LENGTH || VIDEO_DURATION=$V_DURATION 340 340 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}') 342 342 NEED_SPACE=$(expr $CUR_SIZE \* 2) 343 343 yecho "The encoding process will require about" 344 344 # Estimate space based as kbps * duration … … 441 441 ;; 442 442 "-safe" ) 443 443 shift 444 SAFE_AREA=$(echo $1 | sed 's/%//g')444 SAFE_AREA=$(echo $1 | gsed 's/%//g') 445 445 ;; 446 446 "-crop" ) 447 447 USE_FILTERS=1 … … 452 452 USE_FILTERS=1 453 453 shift 454 454 # Parse comma-separated values 455 for FILTER in $(echo "$1" | sed 's/,/ /g'); do455 for FILTER in $(echo "$1" | gsed 's/,/ /g'); do 456 456 case "$FILTER" in 457 457 "none" ) 458 458 DO_DENOISE=false … … 532 532 "-subtitles" ) 533 533 shift 534 534 if test -e "$1"; then 535 SUBS_FILE=$( readlink -f "$1")535 SUBS_FILE=$(greadlink -f "$1") 536 536 SUBTITLES="-sub \"$SUBS_FILE\"" 537 537 DO_SUBS=: 538 538 else … … 675 675 { 676 676 # Get total size of all output files 677 677 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}') 679 679 test -z $FINAL_SIZE && FINAL_SIZE=0 680 680 681 681 if $FAKE; then 682 682 : 683 683 else 684 684 yecho "Output files:" 685 du -shc "$OUT_PREFIX".mpg "$OUT_PREFIX".[0-9].mpg 2>/dev/null685 gdu -shc "$OUT_PREFIX".mpg "$OUT_PREFIX".[0-9].mpg 2>/dev/null 686 686 fi 687 687 688 688 # Create stats directory if it doesn't already exist. … … 747 747 # get lines with frame= , and print last field with kbit/s removed 748 748 bitrates=$(awk -F= '/^frame=/ {gsub("kbits/s", ""); print $NF}' "$LOG_FILE") 749 749 # 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]*$//') 751 751 # average the values. Add 000, so it is in bits. 752 752 AVG_BITRATE=$(awk '{t+=$0} END{printf "%d\n", t/NR}' <<< "$bitrates") 753 753 AVG_BITRATE=${AVG_BITRATE}000 … … 903 903 IN_FILE_TYPE="uri" 904 904 else 905 905 IN_FILE_TYPE="file" 906 IN_FILE=$( readlink -f "$IN_FILE")906 IN_FILE=$(greadlink -f "$IN_FILE") 907 907 fi 908 908 909 909 … … 928 928 OUT_PREFIX="$OUTPUT_DIR/$OUT_PREFIX" 929 929 # Otherwise, use the full qualified pathname 930 930 else 931 OUT_PREFIX=$( readlink -f "$OUT_PREFIX")931 OUT_PREFIX=$(greadlink -f "$OUT_PREFIX") 932 932 mkdir -p "$(dirname "$OUT_PREFIX")" 933 933 fi 934 934 … … 1109 1109 yecho "Probing video for information. This may take several minutes..." 1110 1110 1111 1111 # 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}') 1113 1113 1114 1114 # Assume nothing is compliant unless idvid says so 1115 1115 # (these will be overridden by idvid for compliant A/V) … … 1737 1737 1738 1738 # Remove extraneous commas from filter command 1739 1739 if 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/^,//')" 1741 1741 fi 1742 1742 # ****************************************************************************** 1743 1743 # … … 2113 2113 # ****************************************************************************** 2114 2114 2115 2115 if ! $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}') 2118 2118 # Total size of streams so far (in MBytes) 2119 2119 STREAM_SIZE=$(expr \( $AUDIO_SIZE \+ $VIDEO_SIZE \) \/ 1000000) 2120 2120 # If it exceeds disc size, add '%d' field to allow mplex to split output 2121 2121 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/') 2123 2123 fi 2124 2124 fi 2125 2125