summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xtranscode.sh26
1 files changed, 17 insertions, 9 deletions
diff --git a/transcode.sh b/transcode.sh
index 3f317e6..e333200 100755
--- a/transcode.sh
+++ b/transcode.sh
@@ -175,6 +175,7 @@ _REPORT_SKIPPED_CODEC=0
_REPORT_SKIPPED_LARGER=0
_REPORT_SUCCEEDED=0
_REPORT_TOTAL_ORIGINAL_BYTES=0
+_REPORT_TOTAL_NEW_BYTES=0
_REPORT_TOTAL_SAVED_BYTES=0
###############################################################################
@@ -1150,9 +1151,15 @@ print_size_report_feedback() {
local saved_bytes="$4"
local saved_pct="$5"
- msg "Size report [$status]:" \
- "$(format_filesize "$original_bytes") → $(format_filesize "$new_bytes")," \
- "$(format_filesize "$saved_bytes") saved (${saved_pct}%)"
+ if [[ $saved_bytes -lt 0 ]]; then
+ msg "Size report [$status]:" \
+ "$(format_filesize "$original_bytes") → $(format_filesize "$new_bytes")," \
+ "$(format_filesize "$((-saved_bytes))") larger (${saved_pct}%)"
+ else
+ msg "Size report [$status]:" \
+ "$(format_filesize "$original_bytes") → $(format_filesize "$new_bytes")," \
+ "$(format_filesize "$saved_bytes") saved (${saved_pct}%)"
+ fi
}
# Print the end-of-run size report summary for batch runs.
@@ -1172,12 +1179,12 @@ print_size_report_summary() {
average_saved_pct=$((_REPORT_TOTAL_SAVED_BYTES * 100 / _REPORT_TOTAL_ORIGINAL_BYTES))
fi
- printf "\n${BOLD}${BLUE}Size report summary:${ALL_OFF}\n"
- printf " Encoded: %s\n" "$_REPORT_SUCCEEDED"
- printf " Skipped: %s\n" "$skipped_total"
- printf " Failed: %s\n" "$failed_total"
- printf " Total bytes saved: %s (%s bytes)\n" "$(format_filesize "$_REPORT_TOTAL_SAVED_BYTES")" "$_REPORT_TOTAL_SAVED_BYTES"
- printf " Average saved: %s%%\n" "$average_saved_pct"
+ msg "Size report summary:"
+ printf "${BOLD}${GREEN}Encoded:${ALL_OFF} %s\n" "$_REPORT_SUCCEEDED"
+ printf "${BOLD}${CYAN}Skipped:${ALL_OFF} %s (${BOLD}${YELLOW}Codec:${ALL_OFF} %s / ${BOLD}${YELLOW}Size:${ALL_OFF} %s)\n" "$skipped_total" "$_REPORT_SKIPPED_CODEC" "$_REPORT_SKIPPED_LARGER"
+ printf "${BOLD}${RED}Failed:${ALL_OFF} %s (${BOLD}${YELLOW}Encoding:${ALL_OFF} %s / ${BOLD}${YELLOW}Integrity:${ALL_OFF} %s)\n" "$failed_total" "$_REPORT_ENCODING_FAILED" "$_REPORT_INTEGRITY_FAILED"
+ printf "${BOLD}${MAGENTA}Total bytes saved:${ALL_OFF} %s (${BOLD}${YELLOW}Original:${ALL_OFF} %s / ${BOLD}${YELLOW}New:${ALL_OFF} %s)\n" "$(format_filesize "$_REPORT_TOTAL_SAVED_BYTES")" "$(format_filesize "$_REPORT_TOTAL_ORIGINAL_BYTES")" "$(format_filesize "$_REPORT_TOTAL_NEW_BYTES")"
+ printf "${BOLD}${BLUE}Average saved:${ALL_OFF} %s%%\n" "$average_saved_pct"
}
# Encode a single media file according to PRESET_NAME.
@@ -1441,6 +1448,7 @@ encode_one() {
mv -f -- "$temporary_output_file" "$input_file"
((_REPORT_SUCCEEDED++))
_REPORT_TOTAL_ORIGINAL_BYTES=$((_REPORT_TOTAL_ORIGINAL_BYTES + original_filesize))
+ _REPORT_TOTAL_NEW_BYTES=$((_REPORT_TOTAL_NEW_BYTES + new_filesize))
_REPORT_TOTAL_SAVED_BYTES=$((_REPORT_TOTAL_SAVED_BYTES + filesize_difference))
msg "Replaced:" "$input_file"
else