summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Fink2026-05-14 23:14:33 +0200
committerDennis Fink2026-05-14 23:14:33 +0200
commit7fb7d0844c7e53a922719697b583fd33a1b89970 (patch)
tree1daf3e4f83dc2cc0637d663bf7d40fe7f5c025f6
parentf575518dcfba692367b76507a63568ab3259e47c (diff)
downloadtranscode.sh-7fb7d0844c7e53a922719697b583fd33a1b89970.tar.gz
transcode.sh-7fb7d0844c7e53a922719697b583fd33a1b89970.zip
feat(report): improve size summary output
Track the total encoded output size alongside the original and saved byte counts so the batch summary can show original vs. new totals. Improve size report feedback for larger outputs by printing the byte difference as “larger” instead of showing a negative saved value. Rework the final summary format to include colored encoded, skipped, failed, total-size, and average saving lines, with skipped and failed counts broken down by reason.
-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