From dad27b5f2ce5fb5b907bf3c552164d032d5048fd Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Fri, 22 May 2026 18:53:04 +0200 Subject: refactor(encoding): reuse metadata logging Extract encode_one metadata output into a helper so dry-run and real encoding paths print the same stream information. Use the shared helper before running ffmpeg as well as during dry runs, making verbose output consistent without duplicating the metadata field list. --- transcode.sh | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/transcode.sh b/transcode.sh index b3ced55..b7d19ae 100755 --- a/transcode.sh +++ b/transcode.sh @@ -1084,6 +1084,18 @@ replace_original() { # ENCODING ############################################################################### +# Print metadata collected earlier in encode_one(). +# Intentionally reads encode_one() locals via Bash dynamic scoping. +encode_one_print_metadata() { + verbose "Video stream:" "$VIDEO_STREAM" + verbose "Input codec:" "$input_codec" + verbose "Input pixel format:" "$input_pixel_format" + verbose "Output pixel format:" "$output_pixel_format" + verbose "Input frame rate:" "$input_frame_rate" + verbose "Input FPS:" "$input_fps" + verbose "Output GOP size:" "$output_gop_size" +} + # Encode a single media file according to PRESET_NAME. # # Arguments: @@ -1313,13 +1325,7 @@ encode_one() { if [[ $DRY_RUN -eq 1 ]]; then msg "DRY RUN:" "Would encode with preset $PRESET_NAME" - verbose "Video stream:" "$VIDEO_STREAM" - verbose "Input codec:" "$input_codec" - verbose "Input pixel format:" "$input_pixel_format" - verbose "Output pixel format:" "$output_pixel_format" - verbose "Input frame rate:" "$input_frame_rate" - verbose "Input FPS:" "$input_fps" - verbose "Output GOP size:" "$output_gop_size" + encode_one_print_metadata verbose "Command:" "${encode_cmd[*]}" return $EXIT_OK fi @@ -1329,6 +1335,7 @@ encode_one() { # --------------------------------------------------------------------------- msg "Encoding:" "$input_file" + encode_one_print_metadata if nice -n "$NICE_VALUE" "${encode_cmd[@]}"; then # Integrity verification: confirm the encoded output is a valid, playable -- cgit v1.3.1