Skip to content

Commit

Permalink
fix: show percentage with two decimal digits in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
slhck committed Nov 18, 2024
1 parent 2a2639f commit d21b49d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion ffmpeg_normalize/_media_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
AUDIO_ONLY_FORMATS = {"aac", "ast", "flac", "mka", "oga", "ogg", "opus", "wav"}
ONE_STREAM = {"aac", "ast", "flac", "mp3", "wav"}

TQDM_BAR_FORMAT = "{desc}: {percentage:3.2f}% |{bar}{r_bar}"


def _to_ms(**kwargs: str) -> int:
hour = int(kwargs.get("hour", 0))
Expand Down Expand Up @@ -189,7 +191,12 @@ def run_normalization(self) -> None:

# run the second pass as a whole
if self.ffmpeg_normalize.progress:
with tqdm(total=100, position=1, desc="Second Pass") as pbar:
with tqdm(
total=100,
position=1,
desc="Second Pass",
bar_format=TQDM_BAR_FORMAT,
) as pbar:
for progress in self._second_pass():
pbar.update(progress - pbar.n)
else:
Expand Down Expand Up @@ -225,6 +232,7 @@ def _first_pass(self) -> None:
total=100,
position=1,
desc=f"Stream {index + 1}/{len(self.streams['audio'].values())}",
bar_format=TQDM_BAR_FORMAT,
) as pbar:
for progress in fun():
pbar.update(progress - pbar.n)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tqdm>=4.64.1
colorama>=0.4.6
ffmpeg-progress-yield>=0.7.4
ffmpeg-progress-yield>=0.10.0
colorlog==6.7.0

0 comments on commit d21b49d

Please sign in to comment.