Skip to content

Commit 20ec40a

Browse files
committed
fix: output logs with file names, fixes #313
1 parent e938059 commit 20ec40a

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

src/ffmpeg_normalize/_media_file.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -888,8 +888,8 @@ def _second_pass(self) -> Iterator[float]:
888888
continue
889889
if pass2_stats["normalization_type"] == "dynamic":
890890
_logger.warning(
891-
"You specified linear normalization, but the loudnorm filter reverted to dynamic normalization. "
892-
"This may lead to unexpected results."
891+
f"{self.input_file}: You specified linear normalization, but the loudnorm filter reverted to dynamic normalization. "
892+
"This may lead to unexpected results. "
893893
"Consider your input settings, e.g. choose a lower target level or higher target loudness range."
894894
)
895895

src/ffmpeg_normalize/_streams.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def get_pcm_codec(self) -> str:
201201
return f"pcm_s{self.bit_depth}le"
202202
else:
203203
_logger.warning(
204-
f"Unsupported bit depth {self.bit_depth}, falling back to pcm_s16le"
204+
f"{self.media_file.input_file}: Unsupported bit depth {self.bit_depth}, falling back to pcm_s16le"
205205
)
206206
return "pcm_s16le"
207207

@@ -483,7 +483,7 @@ def get_second_pass_opts_ebu(self, batch_reference: float | None = None) -> str:
483483

484484
if float(self.loudness_statistics["ebu_pass1"]["input_i"]) > 0:
485485
_logger.warning(
486-
"Input file had measured input loudness greater than zero "
486+
f"{self.media_file.input_file}: Input file had measured input loudness greater than zero "
487487
f"({self.loudness_statistics['ebu_pass1']['input_i']}), capping at 0"
488488
)
489489
self.loudness_statistics["ebu_pass1"]["input_i"] = 0
@@ -497,7 +497,7 @@ def get_second_pass_opts_ebu(self, batch_reference: float | None = None) -> str:
497497
input_lra = self.loudness_statistics["ebu_pass1"]["input_lra"]
498498
if input_lra < 1 or input_lra > 50:
499499
_logger.warning(
500-
"Input file had measured loudness range outside of [1,50] "
500+
f"{self.media_file.input_file}: Input file had measured loudness range outside of [1,50] "
501501
f"({input_lra}), capping to allowed range"
502502
)
503503

@@ -527,7 +527,7 @@ def get_second_pass_opts_ebu(self, batch_reference: float | None = None) -> str:
527527
and not will_use_dynamic_mode
528528
):
529529
_logger.warning(
530-
f"Input file had loudness range of {self.loudness_statistics['ebu_pass1']['input_lra']}. "
530+
f"{self.media_file.input_file}: Input file had loudness range of {self.loudness_statistics['ebu_pass1']['input_lra']}. "
531531
f"This is larger than the loudness range target ({self.media_file.ffmpeg_normalize.loudness_range_target}). "
532532
"Normalization will revert to dynamic mode. Choose a higher target loudness range if you want linear normalization. "
533533
"Alternatively, use the --keep-loudness-range-target or --keep-lra-above-loudness-range-target option to keep the target loudness range from "
@@ -552,7 +552,7 @@ def get_second_pass_opts_ebu(self, batch_reference: float | None = None) -> str:
552552
if safe_target < self.ffmpeg_normalize.target_level:
553553
target_level = safe_target
554554
_logger.warning(
555-
f"Using loudness target {target_level} because --auto-lower-loudness-target given.",
555+
f"{self.media_file.input_file}: Using loudness target {target_level} because --auto-lower-loudness-target given.",
556556
)
557557

558558
stats = self.loudness_statistics["ebu_pass1"]
@@ -654,6 +654,8 @@ def get_second_pass_opts_peakrms(self, batch_reference: float | None = None) ->
654654

655655
clip_amount = self.loudness_statistics["max"] + adjustment
656656
if clip_amount > 0:
657-
_logger.warning(f"Adjusting will lead to clipping of {clip_amount} dB")
657+
_logger.warning(
658+
f"{self.media_file.input_file}: Adjusting will lead to clipping of {clip_amount} dB"
659+
)
658660

659661
return f"volume={adjustment}dB"

0 commit comments

Comments
 (0)