From 7ad58bb0a120c56563f333bce142f9772ed00168 Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Wed, 20 May 2026 18:27:59 +0200 Subject: 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. --- transcode.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 ;; -- cgit v1.3.1