summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Fink2026-05-20 18:27:59 +0200
committerDennis Fink2026-05-20 18:27:59 +0200
commit7ad58bb0a120c56563f333bce142f9772ed00168 (patch)
tree26d37c1ee602e16ef4d87726cf645f11d45d9617
parent94c325a5b7c1a12031ce3299445036d79c4e5c85 (diff)
downloadtranscode.sh-7ad58bb0a120c56563f333bce142f9772ed00168.tar.gz
transcode.sh-7ad58bb0a120c56563f333bce142f9772ed00168.zip
fix(color): propagate color mode to ffmpeg
Export ffmpeg/libav color environment variables alongside transcode.sh color detection so subprocess logs follow the same color mode as the wrapper. Set AV_LOG_FORCE_COLOR when colors are forced or stdout is interactive, and set AV_LOG_FORCE_NOCOLOR when NO_COLOR is present or output is non-interactive. Also propagate explicit --color and --no-color choices so later CLI overrides stay consistent with ffmpeg output.
-rwxr-xr-xtranscode.sh12
1 files changed, 12 insertions, 0 deletions
diff --git a/transcode.sh b/transcode.sh
index 20d4684..7f40e3b 100755
--- a/transcode.sh
+++ b/transcode.sh
@@ -1366,18 +1366,26 @@ encode_one() {
# NOTE: This block calls debug() and reads $DEBUG. Both must be defined before
# this point. Do not move this block above the GLOBAL VARIABLES or FUNCTION
# DEFINITIONS sections without adjusting those dependencies.
+#
+# Keep ffmpeg/libav log coloring in sync with transcode.sh's color mode.
+# FFmpeg honors AV_LOG_FORCE_COLOR and AV_LOG_FORCE_NOCOLOR for its own output,
+# so exporting these prevents subprocess logs from using a different color style.
if [[ -n "${NO_COLOR:-}" ]]; then
debug "Colors are disabled via NO_COLOR"
ENABLE_COLOR=0
+ export AV_LOG_FORCE_NOCOLOR=1
elif [[ -n "${FORCE_COLOR:-}" ]]; then
debug "Colors are forced via FORCE_COLOR"
ENABLE_COLOR=1
+ export AV_LOG_FORCE_COLOR=1
elif [[ -t 1 ]]; then
debug "Colors are enabled via interactive terminal"
ENABLE_COLOR=1
+ export AV_LOG_FORCE_COLOR=1
else
debug "Colors are disabled"
ENABLE_COLOR=0
+ export AV_LOG_FORCE_NOCOLOR=1
fi
setup_colors
@@ -1418,11 +1426,15 @@ while [[ $# -gt 0 ]]; do
;;
--color)
ENABLE_COLOR=1
+ # Propagate the explicit color choice to ffmpeg/libav subprocesses.
+ export AV_LOG_FORCE_COLOR=1
setup_colors
shift
;;
--no-color)
ENABLE_COLOR=0
+ # Propagate the explicit color choice to ffmpeg/libav subprocesses.
+ export AV_LOG_FORCE_NOCOLOR=1
setup_colors
shift
;;