diff options
Diffstat (limited to '')
| -rwxr-xr-x | transcode.sh | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/transcode.sh b/transcode.sh index a74b6c3..2866e97 100755 --- a/transcode.sh +++ b/transcode.sh @@ -122,6 +122,7 @@ ONLY_IF_SMALLER=0 PRESET_NAME="default" SAVING=0 SAVING_FILE="transcode_savings" +SAVING_FILE_EXPLICIT=0 declare -A SKIP_CODECS REMAINING_ARGS=() @@ -439,10 +440,18 @@ while [[ $# -gt 0 ]]; do error "Missing value for $1" exit $EXIT_USAGE_ERROR } + [[ -n "$2" ]] || { + error "Value for $1 must not be empty" + exit $EXIT_USAGE_ERROR + } ENCODE_FILE="$2" shift 2 ;; --encodefile=*) + [[ -n "${1#*=}" ]] || { + error "Value for --encodefile must not be empty" + exit $EXIT_USAGE_ERROR + } ENCODE_FILE="${1#*=}" shift ;; @@ -471,11 +480,21 @@ while [[ $# -gt 0 ]]; do error "Missing value for $1" exit $EXIT_USAGE_ERROR } + [[ -n "$2" ]] || { + error "Value for $1 must not be empty" + exit $EXIT_USAGE_ERROR + } SAVING_FILE="$2" + SAVING_FILE_EXPLICIT=1 shift 2 ;; --saving-file=*) + [[ -n "${1#*=}" ]] || { + error "Value for --saving-file must not be empty" + exit $EXIT_USAGE_ERROR + } SAVING_FILE="${1#*=}" + SAVING_FILE_EXPLICIT=1 shift ;; -S | --skip-codec) @@ -499,10 +518,18 @@ while [[ $# -gt 0 ]]; do error "Missing value for $1" exit $EXIT_USAGE_ERROR } + [[ -n "$2" ]] || { + error "Value for $1 must not be empty" + exit $EXIT_USAGE_ERROR + } PRESET_NAME="$2" shift 2 ;; --preset=*) + [[ -n "${1#*=}" ]] || { + error "Value for --preset must not be empty" + exit $EXIT_USAGE_ERROR + } PRESET_NAME="${1#*=}" shift ;; @@ -543,6 +570,10 @@ if [[ $SAVING -eq 1 ]]; then } fi +if [[ $SAVING_FILE_EXPLICIT -eq 1 && $SAVING -eq 0 ]]; then + error "--saving-file has no effect without --saving" +fi + if [[ ! "$NICE_VALUE" =~ ^-?[0-9]+$ ]] || ((NICE_VALUE < -20 || NICE_VALUE > 19)); then error "Invalid nice value (must be an integer between -20 and 19):" "$NICE_VALUE" exit $EXIT_USAGE_ERROR @@ -724,7 +755,11 @@ encode_one() { else pct=0 fi - printf "%s %s %s %s%%\n" "$filename" "$original_filesize" "$new_filesize" "$pct" >>"$SAVING_FILE" + # Write a header line if the savings file does not yet exist. + if [[ ! -f "$SAVING_FILE" ]]; then + printf "filename\toriginal_bytes\tnew_bytes\tsaved_pct\n" >"$SAVING_FILE" + fi + printf "%s\t%s\t%s\t%s%%\n" "$filename" "$original_filesize" "$new_filesize" "$pct" >>"$SAVING_FILE" fi mv -f -- "$tmp" "$file" |
